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

查看:37
本文介绍了触发 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.

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

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天全站免登陆