2012-07-03 16 views
1

我們正在測試鏈接跟蹤解決方案,並且現在想要在兩個不同的帳戶中顯示活動。我們有這樣的設置:將活動推送到多個配置文件

var _gaq = _gaq || []; 
    _gaq.push(
    ['_setAccount', 'UA-516606-1'], 
    ['_trackPageview'], 
    ['_setDomainName', 'du.edu'], 
    ['b._setAccount', 'UA-516606-24'], 
    ['b._trackPageview'], 
    ['b._setDomainName', 'du.edu'] 
); 
(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); 
})(); 

我們使用在http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55527發現了跟蹤代碼,但我沒有訣竅來修改爲多個帳戶。這裏的解決方案:Google analytics event tracking on Multiple accounts not working並不完全適用於此。是否可以添加一個b帳戶到recordOutboundLink函數?

回答

2

您只需要使用不同的recordOutboundLink函數。

function recordOutboundLink(link, category, action) { 
    _gaq.push(
    ['_trackEvent', category, action], 
    ['b._trackEvent', category, action] 
); 
    setTimeout('document.location = "' + link.href + '"', 100); 
} 

然後你的鏈接

<a href="http://www.example.com" onClick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;"> 
+0

謝謝,愛德華。這似乎已經成功了。 –