如何跟踪Facebook页面中嵌入的链接?

时间:2013-03-07 07:23:13

标签: php javascript codeigniter google-analytics

我想从我的脸书页面跟踪新闻稿标签。 我把这段代码放在我网站的源代码中:

<head>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

 </head>
 <body>

    <script type="text/javascript">
           var fb_param = {};
           fb_param.pixel_id = 'xxxxxxxxxx';
           fb_param.value = '0.00';
           (function(){
             var fpw = document.createElement('script');
             fpw.async = true;
             fpw.src = (location.protocol=='http:'?'http':'https')+'://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=xxxxxxxxx&amp;value=0" />
   </noscript>


 </body>

够了吗?

1 个答案:

答案 0 :(得分:1)

只要您的来源中包含Google代码,Google就会自动跟踪推介。如果您可以修改Facebook页面中的嵌入式链接,您可能需要查看将_utm变量添加到网址中。 Google会自动通过网址识别此内容,并在您的GA帐户中添加这些参数。要构建或获取有关_utm变量的更多信息,请访问:https://support.google.com/analytics/answer/1033863

我会将utm_source设置为facebook,将utm_medium设置为newsletter-tab:

http://www.example.com/?utm_source=facebook&utm_medium=newsletter-tab