开发者

google analytics code is not recording the traffic?

开发者 https://www.devze.com 2022-12-19 11:45 出处:网络
One of my client\'s site\'s google analytics code is not working. What is the problem in this code? <script type=\'text/javascript\'>

One of my client's site's google analytics code is not working.

What is the problem in this code?

<script type='text/javascript'>
var gaJsHost = ((&quot;https:&quot; == document.location.pr开发者_开发问答otocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);


document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));


</script>
<script type='text/javascript'>
try {
var pageTracker = _gat._getTracker(&quot;UA-8830811-1&quot;);


pageTracker._trackPageview();
} catch(err) {}</script>


The problem is all the extra entity encoding (i.e. &quot; etc). Additionally, once you use the right code it can take up to 24 hours for it to start showing data, though usually within a few hours it will show a green "√" to signify the tracking code is installed correctly. Use this instead:

<script type='text/javascript'>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type='text/javascript'>
try {
  var pageTracker = _gat._getTracker("UA-8830811-1");
  pageTracker._trackPageview();
} catch(err) {}
</script>​​
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号