How do I get Google Analytics to track individual images on a slideshow?

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.com']);
  _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>

BTW you might need to wait for the document to be ready / loaded before executing the _gaq.push line :)


I'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.com/apis/analytics/docs/tracking/eventTrackerGuide.html

......

链接地址: http://www.djcxy.com/p/53284.html

上一篇: 在PHP中嵌入来自数据库的视频JavaScript代码

下一篇: 如何让Google Analytics(分析)跟踪幻灯片上的单个图像?