admin管理员组文章数量:1391999
It is the first time i am using the new version of Google Analytics (Universal Analytics), so when i put the below code imediatally before </head>
i get blank pages for all my URLs.
Here is the code given by Google:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics/analytics.js','ga');
ga('create', 'UA-1234567-89', 'mysite');
ga('send', 'pageview');
</script>
Someone knows why it is happening? Seems to be a bug, but i don't know how to solve this.
It is the first time i am using the new version of Google Analytics (Universal Analytics), so when i put the below code imediatally before </head>
i get blank pages for all my URLs.
Here is the code given by Google:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics./analytics.js','ga');
ga('create', 'UA-1234567-89', 'mysite.');
ga('send', 'pageview');
</script>
Someone knows why it is happening? Seems to be a bug, but i don't know how to solve this.
Share Improve this question edited Oct 22, 2013 at 11:37 Marcio Mazzucato asked Oct 21, 2013 at 18:39 Marcio MazzucatoMarcio Mazzucato 9,31511 gold badges70 silver badges81 bronze badges 9- 1 Try debugging in your browser's dev tools. I would open the Chrome "Network" panel to see if there are any redirects taking place, or any JS / HTML loaded that is breaking the site. Use the "Preserve Log upon Navigation" option to make sure you don't miss anything. Also look for JS errors in the Console. – providencemac Commented Oct 21, 2013 at 18:51
- @providencemac, The page is ming totally empty. If i remove the tracking code it works normally. This is very strange – Marcio Mazzucato Commented Oct 21, 2013 at 18:55
- 1 Can you share you site with Universal Analytics in it (the empty page)? Are there any errors in the console? – Nick Blexrud Commented Oct 21, 2013 at 19:13
- 1 @MarcioSimao This problem is server-side, if there is no data being sent to the client as you claim. Sounds like you have a template engine that doesn't like JavaScript. – Brad Commented Oct 21, 2013 at 21:14
-
1
@MarcioSimao Ha, I wondered. I also use Smarty and have had this exact same problem before.
{literal}
tags are what you need, since Smarty uses brackets by default for its delimeters. – Brad Commented Oct 21, 2013 at 22:42
1 Answer
Reset to default 8Based on @Brad ment i detected that PHP Smarty was crashing with Universal Analytics code tracking, so i found this post:
Use {Literal} Smarty Tag to Add Google Analytics Tracking Code to BlogSome Hosted Blogs
And then i did like below and the tracking code works perfectly!
<script>
{literal}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics./analytics.js','ga');
ga('create', 'UA-1234567-89', 'mysite.');
ga('send', 'pageview');
{/literal}
</script>
本文标签: javascriptGoogle Universal Analytics tracking code generating an empty pageStack Overflow
版权声明:本文标题:javascript - Google Universal Analytics tracking code generating an empty page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744607408a2615440.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论