Virtual page views with a variable
Let’s say that you want to be able to track click elements that do not result in Page load. It immediately would give you a more detailed overview of your user-base.
Every time you are moving from the main page of help.piwik.pro to the subpages (please take a look at the screenshots below), instead of redirecting you to the different URL, it adds a name of a given subpage after a hashtag to the main page URL.
We can create a Variable. As “Name” it will pass an element of “Click Subpage” tag. Next, we can create one Tag that would be fired every time when the subpage link was clicked.
To do it step-by-step:
var anchor = window.location.href.split('#')
2. Now we need to create a tag “Click subpage link” with the trigger adapted to your page. Here its type will be “Click” and the tag will be fired when the conditions are met (in this particular example it would be “Click URL contains help.piwik.pro”).
3. We could have achieved the same result by creating different virtual page view tag for each element, but in the case of websites with a number of such elements – it would not be a manageable solution. Last but not least, this is how it looks in the Visitor Log: