2012-03-29 72 views
0

Google Analytics代碼看起來與Google網站優化工具(GWO)*相同;兩者均來自http://www.google-analytics.com/ga.js。然而,在GA和GWO管理面板上,Google要求我們包含(即複製粘貼)其各自的跟蹤代碼,這兩個代碼均包含與ga.js相同的參考。也許只是爲了教學簡單?因此,當他們想要同時啓用GA跟蹤和A/B測試時,我看到多個頁面對ga.js有冗餘引用。爲Google Analytics(GA)和Google網站優化工具(GWO)預防ga.js的重複工作

我的問題是我們可以做到以下幾點嗎?希望對於那些不熟悉JavaScript,但需要配置GA和GWO的人來說,這會很有用。

<head> 
<script> 
var _gaq = _gaq || []; 
_gaq.push(['gwo._setAccount', 'UA-xxxxxxx-x']); 
_gaq.push(['gwo._trackPageview', '/yyyyyyyyyy/test']); 
</script> 
<!-- All other meta tags. --> 

<!-- Let this script serves both for the regular GA tracking and GWO A/B test. --> 
<script> 
(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> 

* GWO腳本通常用於A/B測試。

+0

爲什麼不測試它看看會發生什麼? – 2012-03-29 07:34:06

回答

0

是的,您可以包含snipet函數一次,但您缺少配置的GA部分。

相關問題