触发Facebook转换像素 [英] Firing the Facebook Conversion Pixel

查看:80
本文介绍了触发Facebook转换像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Javascript还是很陌生,但是我想知道在不实际加载确认"/谢谢"页面的情况下触发Facebook转换像素(如下)的最佳方法是什么?

I'm still pretty new to Javascript, but I was wondering what would be the best way to fire the Facebook conversion pixel (below) without actually loading a "confirmation"/"Thank You" page?

<script type="text/javascript">
var fb_param = {};
fb_param.pixel_id = 'XXXXXXXXXXX';
fb_param.value = '0.00';
fb_param.currency = 'USD';
(function(){
  var fpw = document.createElement('script');
  fpw.async = true;
  fpw.src = '//connect.facebook.net/en_US/fp.js';
  var ref = document.getElementsByTagName('script')[0];
  ref.parentNode.insertBefore(fpw, ref);
})();
</script>
<noscript><img height="1" width="1" alt="" style="display:none"
src="https://www.facebook.com/offsite_event.php?id=XXXXXXXXXX&amp;value=0&amp;currency=USD" /></noscript>

Facebook表示,我们应该将其插入访问者进行转换(填写表格,进行购买等)后看到的谢谢页面"中.但是,我们的某些表单是弹出式窗口或内容栏上的表单,位于内容旁边,我们不希望读者通过确认页面将其引导离开.

Facebook says that we should plug this into our "Thank You pages" that visitors see after they convert (fill out a form, make a purchase, etc). However, some of our forms are popups or forms on sidebars next to content that we don't want readers to be directed away from by a confirmation page.

使用Google Analytics(分析),可以通过触发_gaq.push(['_ trackPageview'])创建不可见"的网页浏览.可以告诉GA的代码,它应该将不可见的网页浏览量视为目标达成情况.

With Google Analytics, I can create an "invisible" pageview by firing _gaq.push(['_trackPageview']); code that can tell GA that it should count that invisible pageview as a goal completion.

是否有类似的东西足以让我的网站触发FB像素?

Is there something similar to that that's general enough to tell my site to fire the FB pixel?

推荐答案

由于我之前提到的内容无效,因此我更新了代码.感谢@Flambino指出.

I've updated my code as what I had mentioned previously did not work. Thanks to @Flambino to pointing out.

这是我使用像素而不是脚本传递转换像素的修订版答案.我参考了如何跟踪onclick上的Google Adwords转化?帖子:

This is my revised answer using a pixel rather than a script to pass the conversion pixel. I reference the How to track a Google Adwords conversion onclick? SO post:

<head>
<script type="text/javascript"> 
function facebookConversionPixel(fb_pixel, fb_value){
    var image = new Image(1,1); 
    image.src = "//www.facebook.com/offsite_event.php?id=" + fb_pixel + "&amp;value=" + fb_value + "&amp;currency=USD";
}
</script>
</head>

<body>
<a href="#" onclick="facebookConversionPixel(123456,0.00);">FBCONV</a>
</body>

这篇关于触发Facebook转换像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆