[英]Social tracking in Google Analytics
我正在使用這個示例腳本,該示例腳本由Google在Rails應用程序內提供(因此,它由Rails與我所有其他腳本一起編譯成一個JS文件):
_ga.trackSocial = function(opt_pageUrl, opt_trackerName) {
_ga.trackFacebook(opt_pageUrl, opt_trackerName);
_ga.trackTwitter(opt_pageUrl, opt_trackerName);
};
/**
* Tracks Facebook likes, unlikes and sends by suscribing to the Facebook
* JSAPI event model. Note: This will not track facebook buttons using the
* iFrame method.
* @param {string} opt_pageUrl An optional URL to associate the social
* tracking with a particular page.
* @param {string} opt_trackerName An optional name for the tracker object.
*/
_ga.trackFacebook = function(opt_pageUrl, opt_trackerName) {
var trackerName = _ga.buildTrackerName_(opt_trackerName);
try {
if (FB && FB.Event && FB.Event.subscribe) {
FB.Event.subscribe('edge.create', function(targetUrl) {
_gaq.push([trackerName + '_trackSocial', 'facebook', 'like',
targetUrl, opt_pageUrl]);
});
FB.Event.subscribe('edge.remove', function(targetUrl) {
_gaq.push([trackerName + '_trackSocial', 'facebook', 'unlike',
targetUrl, opt_pageUrl]);
});
FB.Event.subscribe('message.send', function(targetUrl) {
_gaq.push([trackerName + '_trackSocial', 'facebook', 'send',
targetUrl, opt_pageUrl]);
});
}
} catch (e) {}
};
然后,此代碼加載我的Facebook喜歡按鈕:
<div id="fb-root" class="fb_like"></div>
<script src="http://connect.facebook.net/en_US/all.js#appId=...&xfbml=1"></script>
<fb:like href="http://somethingunderthewater.com" send="true" layout="standard" colorscheme="light" width="400" show_faces="false" font="trebuchet ms"></fb:like>
但是,盡管Google跟蹤+1按鈕,但它並未跟蹤Facebook之類的事件,而且我對JS的了解不足,無法弄清問題所在。 我看到了有關iFrame方法的注釋,但不認為這就是我的代碼加載方式-也許我錯了?
嘗試在按鈕之前添加以下腳本:
<script type="text/javascript">_ga.trackFacebook();</script>
之后
<script src="http://connect.facebook.net/en_US/all.js#appId=...&xfbml=1"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.