If you want to track banners or images in your image gallery you can do it using Google Web Analytics, but it’s important to do it right otherwise you may end up inflating your metrics and can screw up your web analytics data. Please note, the intent of this process is to track Image loads, not Image Downloads. Image tracking is not included with Google analytics by default, but there is a way of tracking image loads using Event Tracking.
Example:
So if you have an image “physicians.jpg”
<img src="images/physicians.jpg" />
<img src="images/physicians.jpg" onload="_gaq.push(['_trackEvent','Banner Tracking','Physicians Banner','Physicians Tracking']);" />
- onload function will trigger an event once the image loads
- name and categorize your event accordingly, in the example above
‘Banner Tracking’ represents Category
‘Physicians Banner’ represents Action
‘Physicians Tracking’ represents Label
Note: only Category and Action strings are required, additional values are optional.
Event Tracking Configuration
- Call the
_trackEvent()
method in the source code of a page object, widget, or video.
The specification for the_trackEvent()
method is:_trackEvent(category, action, opt_label, opt_value, opt_noninteraction)
- category (required)The name you supply for the group of objects you want to track.
- action (required)A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.
- label (optional)An optional string to provide additional dimensions to the event data.
- value (optional)An integer that you can use to provide numerical data about the user event.
- non-interaction (optional)A boolean that when set to
true
, indicates that the event hit will not be used in bounce-rate calculation.