-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi everyone,
I am looking for a way to add the script provided by Google Analytics into a zul page.
According to Google, the script must be place right before the </head> tag.
I already read this: http://books.zkoss.org/wiki/ZK_Developer's_Reference/Integration/Google_Analytics
But this is not what I want.
I don't want to track ajax request. All I want is that the Google Analytics script should be run once the zul page is opened. That's it. No ajax.
I use this code in login.zul
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'YOUR ACCOUNT']); _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>
Best regards.
Yeah, but where exactly do you put it in the ZUL file?
I am asking because Google says it's best to put it before the </head> tag in the html site.
Try with this code:
Publish and then see source code from html.
<zk> <window id="win" width="400px" top="100px" style="margin-left:auto;margin-right:auto;margin-top:150px"> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-15607597-3']); _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> </window> </zk>
Best regards
Asked: 2011-07-26 11:25:13 +0800
Seen: 292 times
Last updated: Jul 27 '11