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 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:

1. Let’s create an “Anchor” Variable – a Variable (Custom JavaScript) that takes last part (after “#”) out of the URL:

function() {
var anchor = window.location.href.split('#')[1]
return anchor;

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”).

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:

Was this article helpful?

Be the first to rate this article.

Technical Support

If you have any questions, drop us a line at

We’re happy to help!