1
我正在使用Google Analytics的新异步代码,在同一页面调用两次GA.js是否正确,如果不是,有没有办法做到这一点?谷歌分析异步代码
我的问题是我需要在使用闪光灯的预订表单上记录两个PageViews,问题在于用户可能不需要进入第二阶段,但在第一阶段关闭窗口。
<!-- Step one, I need to record a pageview -->
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6173481-3']);
_gaq.push(['_trackPageview', '/Step1']);
(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);
})();
<!-- Step two of the process i define a function that will get called by flash and record another pageview-->
function completed(){
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6173481-3']);
_gaq.push(['_trackPageview', '/Step2']);
(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);
})();
}