Data, data and more data
Digital Analytics

Tracking events in virtual pages with Google Analytics

13/03/2013
Tracking events in virtual pages with Google Analytics

Let's take this hypothetical stage: our site has a page which has two views ("A" and "B") under a same url ("www.oursite.com/a"). Both "A" and "B" views have buttons we want to track.

First, we'll make use of virtual pages tagging:

When "A" is in view, (at url "/a"), we'll use:

_gaq.push(['_trackPageview', '']);

When an user clicks on a button in "A", we'll tag:

_gaq.push(['_trackEvent', 'A', 'evento-A']);

To track that "B" view (it's under that same url "/a") we'll use virtual tagging:

_gaq.push(['_trackPageview', '/b']);

Same, when an user clicks on a button in "B" view:

_gaq.push(['_trackEvent', 'B', 'evento-B']);

Okey dokey.

However, if we now check the Events report in Google Analytics we'll find out that that button event from the "B" view is registered under page "/a". This happens because GA associates current browser url to the triggered event. Thus, if we look at the __utm.gif request linked to the "B" view button, utmp parameter will be /a.

If we'd like to register all the events associated to "B" in a separate profile, an "include “/b”" (or exclude all the rest) filter won't work: include and exclude by uri filters use the utmp parameter.

Can we modify the utmp parameter? In order to associate events to a virtual view, we'll send a “page” “_set” before the virtual “_trackPageview”. For instance:

_gaq.push([‘set’,’page’,’/b’]) _gaq.push([‘_trackPageview’,’/b’]);

This way, if we look at the parameter after sending an event from view "B", we'll get:

utmp=%2Fb

Now, going back to Google Analytics reports, all the events that weren't being registered before are there!

Next Previous
This website uses cookies. If you continue browsing we consider that you agree our Cookie policy.