我需要将两个谷歌分析添加到一个页面
脚本 1
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-1']);
_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>
脚本 2
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxx-2']); _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>
我可以将这两个脚本分别添加到我的 html 页面中吗?
我看到了组合 2 个脚本之类的方法
<script type="text/javascript">
var trackerA = _gat._getTracker("UA-XXXXXXX-X");
trackerA._initData();
trackerA._trackPageview();
var trackerB = _gat._getTracker("UA-XXXXXXX-X");
trackerB._initData();
trackerB._trackPageview();
</script>
我担心的是,我们可以单独添加脚本吗?请帮忙。