admin管理员组文章数量:1390626
I have a jQuery slideshow, I'm using the cycle plugin. I'm decent with jQuery, but I don't know how I should tie it in with Google Analytics to show me how many times each image is requested.
I've looked around online but I haven't been able to find any good documentation for it.
Can someone give me a simple example and maybe a link to the documentation supporting the example?
Thanks!
Edit:
The key is just to use this code to send an event:
_gaq.push(['_trackEvent', 'PageLocation', location.href]);
But you need to have the asyncronous syntax of calling Google Analytics, which will probably look something like this:
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxxx-1']); _gaq.push(['_setDomainName', 'site']); _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/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>
BTW you might need to wait for the document to be ready / loaded before executing the _gaq.push line :)
I have a jQuery slideshow, I'm using the cycle plugin. I'm decent with jQuery, but I don't know how I should tie it in with Google Analytics to show me how many times each image is requested.
I've looked around online but I haven't been able to find any good documentation for it.
Can someone give me a simple example and maybe a link to the documentation supporting the example?
Thanks!
Edit:
The key is just to use this code to send an event:
_gaq.push(['_trackEvent', 'PageLocation', location.href]);
But you need to have the asyncronous syntax of calling Google Analytics, which will probably look something like this:
<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxxx-1']); _gaq.push(['_setDomainName', 'site.']); _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./ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>
BTW you might need to wait for the document to be ready / loaded before executing the _gaq.push line :)
Share Improve this question edited Apr 1, 2011 at 0:54 cwd asked Mar 30, 2011 at 2:33 cwdcwd 54.9k55 gold badges171 silver badges199 bronze badges 2- I'd love to help, but I don't know what you're looking at. Perhaps you can provide some sample code. – Yahel Commented Mar 30, 2011 at 2:35
- I tried to clarify a little. It's working for me now, the edit was help others. – cwd Commented Apr 1, 2011 at 0:38
1 Answer
Reset to default 4I'm not sure why you would want to do this. Analytics is about the page in relation to how the users interact with it.
If you had a random image being shown first on a page it could be useful to know which one is causing the biggest bouncerate, or if your images in the slideshow were hyperlinked and you wanted to know which one is gathering the most click-through to other pages, but the ammount of times an image is loaded is a pretty arbitrary statistic.
Event tracking is probably what you should be looking at, but im unsure of what you are trying to do with the tracking data... if you give a better explanation id be more then happy to help.
http://code.google./apis/analytics/docs/tracking/eventTrackerGuide.html
......
本文标签: javascriptHow do I get Google Analytics to track individual images on a slideshowStack Overflow
版权声明:本文标题:javascript - How do I get Google Analytics to track individual images on a slideshow? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744666375a2618556.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论