Welcome to Part 7 where we’ll look at the Google Analytics virtual pageviews and events. You can find the previous chapters of the guide here:
1. Google Tag Manager
2. Tracking code
3. Check the implementation
4. Profiles and filters
5. Settings
6. Goals setup
7. Virtual pageviews and events
As mentioned in the Goals setup section, there’s a number of situations where you need to implement additionally a special tracking like virtual pageviews or events. It’s very important to determine in advance all elements you want to track and adopt a consistent and clear naming convention – this will help create a clear reporting structure. You can use event tracking for any flash element, AJAX elements, page gadgets, file downloads, load times for data, etc.
The Virtual pageview uses the _trackPageview() function to assign a path/page name to the element you want to track:
onclick=”_gaq.push([‘_trackPageview’, ‘/virtual/download/pdf1.pdf’]);”
All user activity on such elements is calculated and displayed as Pages in the Google Analytics reporting interface. Here’s how the code for a virtual pageview looks like:
<a href=”#” onclick=”_gaq.push([‘_trackPageview’, ‘/virtual/download/pdf1.pdf’]);”>click me</a>
One of the disadvantages of using pageviews is that they artificially increase the number of pageviews. A best practice when using virtual pageviews is to have a clear naming convention, for example start all your pageviews with /v/something/ or /virtual/something/ so they can be easily excluded in a new profile.
The Virtual event uses the _trackEvent() function to set up categories, actions, and labels for the content you want to track.
onclick=”_gaq.push([‘_trackEvent’, ‘category’, ‘action’, ‘opt_label’, opt_value]);”
Let’s look at the virtual event components:
- Category – this would be the name which will group the objects you’re tracking, e.g. videos
- Action – describes the type of event or interaction you track for a particular object, e.g. play, stop, etc.
- Label – the label is optional, and it’s used to provide additional information, e.g. video-name
- Value – the value is also optional, e.g. it could be the time in seconds for a video player to load
All user activity on such elements is calculated and displayed as Events in the Google Analytics reporting interface. Here’s how the code for a virtual event looks like:
<a href=”#” onclick=”_gaq.push([‘_trackEvent’, ‘category’, ‘action’, ‘opt_label’, opt_value]);”>click me</a>
Please note that as explained in the Tracking code section, using virtual events will impact your bounce rate metric because it’s considered an interaction request.
Go to the next chapters of the guide:
8. Campaign tracking
9. Advanced segments and custom reports. Dashboards.
10. Custom alerts
Or jump to the whole thing: Google Analytics Implementation Guide.
Still have questions? You can ask them as comments below and I’ll try to answer.