Javascript 希望使用旧代码从google-analytics.com/ga.js更新到stats.g.doubleclick.net/dc.js
我想将google-analytics.com/ga.js更改为stats.g.doubleclick.net/dc.js 我当前的代码(旧的,但不敢更改——继承的)是Javascript 希望使用旧代码从google-analytics.com/ga.js更新到stats.g.doubleclick.net/dc.js,javascript,google-analytics,Javascript,Google Analytics,我想将google-analytics.com/ga.js更改为stats.g.doubleclick.net/dc.js 我当前的代码(旧的,但不敢更改——继承的)是 var gaJsHost=((“https:==document.location.protocol)?”https://ssl." : "http://www."); write(unescape(“%3Cscript src=”+gaJsHost+“google analytics.com/ga.js”type='te
var gaJsHost=((“https:==document.location.protocol)?”https://ssl." : "http://www.");
write(unescape(“%3Cscript src=”+gaJsHost+“google analytics.com/ga.js”type='text/javascript'%3E%3C/script%3E”);
试一试{
var pageTracker=_gat._getTracker('UA-051510-6');
pageTracker._setDomainName('mydomain.org');
pageTracker._addIgnoredOrganic('mydomain.org');
页面跟踪器。\u setallowash(假);
pageTracker._SetAllowLink(正确);
页面跟踪器。_trackPageview();
}捕获(错误){}
我试着把它改成
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "stats.g.doubleclick.net/dc.js' type='text/javascript'%3E%3C/script%3E"));
</script>
var gaJsHost=((“https:==document.location.protocol)?”https://ssl." : "http://www.");
write(unescape(“%3Cscript src=”+gaJsHost+”stats.g.doubleclick.net/dc.js”type='text/javascript'%3E%3C/script%3E”);
但由于它在localhost:dc.js中查找,因此出现了一个错误,表示无法加载
感谢您的帮助 我认为您应该更新到经典异步代码(Universal Analytics还不支持双击),如下所示:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-051510-6']);
_gaq.push(['_setDomainName', 'mydomain.org']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_addIgnoredOrganic', 'mydomain.org']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
var _gaq=_gaq | |[];
_gaq.push([''设置帐户','UA-051510-6']);
_gaq.push([''u setDomainName','mydomain.org']);
_gaq.push([''设置Allowlinker',true]);
_gaq.push(['''u addIgnoredOrganic','mydomain.org']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://':'http://')+'stats.g.doubleclick.net/dc.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
_SetAllowash不受欢迎感谢所有帮助过他的人。基本上,我只需要删除www,因为它正在拉www.stats.g.doubleclick.net/dc.js 所以最后的代码是
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://");
document.write(unescape("%3Cscript src='" + gaJsHost + "stats.g.doubleclick.net/dc.js' type='text/javascript'%3E%3C/script%3E"));
</script>
var gaJsHost=((“https:==document.location.protocol)?”https://ssl.“:“http:/”;
write(unescape(“%3Cscript src=”+gaJsHost+”stats.g.doubleclick.net/dc.js”type='text/javascript'%3E%3C/script%3E”);
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://");
document.write(unescape("%3Cscript src='" + gaJsHost + "stats.g.doubleclick.net/dc.js' type='text/javascript'%3E%3C/script%3E"));
</script>