English Posts

How to track Virtual Pages: Google Tag Manager and Google Analytics

how to track virtual pages with gtm and ga

In this post, we see how to track Virtual Pages with the help of Google Tag Manager and Google Analytics.

If you don’t know what Virtual Pages are and learn more about how they can help you especially if you are tracking a Single Page Application, I suggest you to read my dedicated post.

To better follow the different steps I will take, let’s imagine this kind of situation: I want to implement virtual pages within a sellout funnel.

My funnel behaves like this:

  • Step 1: The URL you upload is www.example.com/product123#/account
  • Step 2: The URL you upload is www.example.com/product123#/order
  • Step 3: The URL you upload is www.example.com/product123#/shipping
  • Step 4: The URL you upload is www.example.com/product123#/thank-you

By default, in Google Analytics I am unable to collect values ​​after the # symbol (account, order, shipping, thank-you).

For this reason I need to create a virtual page in each step of the checkout.

Let’s begin!

Virtual Pages: create a new tag

The steps to take within Google Tag Manager are as follows:

  1. Create a new Tag by clicking on Tag> New:
create a new tag in google tag manager

2. Select the type of tag (we select the Google Analytics tag: Universal Analytics):

tag google analytics

3. We select the type of hit for this tag: we choose the pageview hit:

hit pageview google tag manager

4. We select the Google Analytics variable, in order to send the information to the Property that interests us:

google analytics settings variable

5. We select the Enable overriding settings in this tag and click on More Settings> Fields to set:

fields to set google tag manager

6. In this field we will create our virtual page by entering the page we want to create and the title of the same. Click on Add Field and write in ‘page‘, while in the “Value” block we insert the path of the page we want to create: I will use ‘/step-1-account‘:

create a virtual page tag

7. Now we have to insert another field to give a Title to this virtual page. Click on Add Field and enter ‘title‘ and in the “Value” block the title you want to give to the page: I will write ‘Checkout Step 1- Account‘ to acknowledge that it is the first step of the checkout.

page title of the virtual page

8. Let’s give our tag a name.

save a tag in google tag manager

Recap: we created the tag and entered the path of the virtual page and its title. We have also selected the Google Analytics variable to indicate which tool to send the information to.

We continue by inserting the trigger to activate our tag under certain conditions.

Virtual Pages: Create a new trigger

Now we need to create the trigger in order to fire the tag in certain situations.

In this case a lot depends on the type of website you are tracking and when you want to activate your tag. The indications below are indicative and may vary, depending on what you want to track in your case.

As mentioned above, I want to send my virtual page when the user is in the first step of the sellout funnel which, in my example was in this URL: www.example.com/product123#/account.

  1. I create my own History Change trigger:
history change trigger tag manager

2. Select the item Some History Changes:

some history change google tag manager

3. Now select the Choose Built-in Variable item from the list:

new buil-in variable tag manager

4. We look for the variable that is called New history Fragment from the list:

new history fragment variabile

5. We select the variable to enable it and make it available in the future in Google Tag Manager and in the value field enter the ‘/ account‘ item that is present within the URL, so that GTM will be able to read the value after the # symbol

new history fragment

6. Let’s name the trigger and save:

save a trigger

Recap: we have associated to our tag the trigger to read the value of the URL after the # symbol.

Now let’s save and test everything.

This process must be done for all the pages of the sellout that we want to track and in which we want to insert virtual pages.

If I go back to my initial example, this means that in each of these pages of the website, the following virtual page will be shot:

  • Step 1: site page www.example.com/product123#/account -> virtual page created in GTM: /step-1-account
  • Step 2: site page www.example.com/product123#/order -> virtual page created in GTM: /step-2-order
  • Step 3: site page www.example.com/product123#/shipping -> virtual page created in GTM: /step-3-shipping
  • Step 4: site page www.example.com/product123#/thank-you -> virtual page created in GTM: /step-4-thank-you

A tag and trigger must be created for each page as described above.

Virtual Pages: Create a Goal in Google Analytics

Now that we’ve created the tags and triggers, a virtual page will be created on each page of the checkout funnel website.

We can now use these virtual pages to create a new Goal in Google Analytics.

The purpose of this Goal is to show us every time a user arrives at the Thank you page by passing through every page of the funnel.

In this case, we need to go to in the Admin section and, within the View where we want to set the goal, create a new Destination Goal.

Here’s how to do it. Let’s create a new Goal in the GA view.

new goal google analytics

We select a custom type template and give a talking name to the Goal, for example: “Checkout Completed”

custom goal google analytics

We select the Destination as the type of Goal: this means that my goal will be completed if the designeted destination is reached.

destination goal google analytics

Click on Continue and enter various information:

  1. the landing page, that is the thank-you page that must be reached by the user to complete the Goal
  2. let’s activate the Funnel option
  3. We insert the name of the Page (the “title” value written in the GTM Tag in the previous steps)
  4. We insert the URL of the virtual page we created (the “page” value written in the GTM tag)
destination goal google analytics

Once the new Goal is set, you will be able to see the conversions in the dedicated report:

rapporto conversioni google analytics

Good analysis!


You may also be interesting by the following articles:

  • Content Grouping in Google Analytics
    Analyzing the contents of a website, has it ever happened to you that you want to know what are the performances of the main sections? Each website is divided into sections, which reflect the organization of its contents. This applies to all sites, from e-commerce, which have sections of product categories, type of articles, sellout […]
  • Google Tag Manager: Lookup Table Variable
    The Lookup Table variable in Google Tag Manager allows you to read the value of an input and, if this value matches certain requirements, it will return some output. There are several situations where this variable can help us: rename a web page, rename the Source dimension for a social (Instagram, Facebook LinkedIn etc.) and […]
  • What Virtual Pages are in Google Analytics
    Pageviews are one of the best known metrics, present in almost all web analytics reports. This metric is populated with pageview hits, which are sent to Google Analytics every time we view a page or refresh the page itself. However, in recent years a series of technologies have developed that improve user navigation on the […]
  • How to track Virtual Pages: Google Tag Manager and Google Analytics
    In this post, we see how to track Virtual Pages with the help of Google Tag Manager and Google Analytics. If you don’t know what Virtual Pages are and learn more about how they can help you especially if you are tracking a Single Page Application, I suggest you to read my dedicated post. To […]
  • Google Analytics 4: Cross Domain Tracking
    In this post I’ll show you how to implement cross domain tracking in the new version of Google Analytics 4. With GA4 cross domain tracking is much easier than the Universal Analytics version, in fact: in Universal Analytics you had to set everything up within Google Tag Manager In Google Analytics 4 you can do […]
  • Google Analytics 4: Referral Exclusion List
    Referral traffic is, generally, traffic from other websites that contain one or more links to your site. The new Google Analytics 4 allows you to measure this kind of traffic for your analysis, without the use of tags, triggers or variables. Proper implementation of referral traffic allows you to understand which other websites are bringing […]
  • Google Analytics 4 Demo Account
    Google has just released the Demo Account for Google Analytics 4 Now, all users can access and discover the functionalities offered by GA4. But let’s go in order! Post Content: 1) What is the Google Analytics 4 Demo Account 2) How the Demo Account is implemented 3) What can I do with the Demo Account […]
  • Form tracking in Google Analytics 4
    In this post, I’m going to show you how to track a Form with Google Analytics 4 and Google Tag Manager. If you want to track the Lead of a user who fills out the Form on your website, firstly you must have created a new Property for GA4 and secondly created a tag in […]

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *