What is the requirement of Virtual Page Views?

While working on a single page website(SPA) or any JavaScript based(ReactJS, AngularJS, BackBoneJS, etc) websites, the interactions of user actions are not straight forward and most of the content is rendered via JavaScript AJAX calls, without reloading the page.

Virtual Pageview: It’s not really a page view but are user actions which are tracked like the real page views. Some examples of them are:
– Infinite Scroll, Load more, Pagination.

– Lightbox, Modal box.

Events which are the core feature of Google Analytics allows tracking user interactions based on specific triggers.
Now, I’ll Show you how you can track the virtual pageviews with GTM(Google Tag Manager) V2:

1. Firstly, we need to setup Google Tag Manager and its container.

2. Setup GTM Data Layer Variables required:


Go to Variables -> User Defined Variables -> New

Setup variable named “virtualPageURL“:

Variable Page Url

Setup variable named “virtualPageTitle“:


Here the variables created for Virtual Pageview:


3. Setup GTM Virtual PageView Trigger:

Go to Triggers -> New

Choose Event as “Custom Event” and complete the required details:


4. On the website put the tracking javascript as per the requirement(load more, ajax infinite scroll, lightbox):

<script type="text/javascript">
      'virtualPageTitle':'News Page - 2'


5. Finally Setup the GTM Virtual PageView Tag:

Go to Tags -> New

– Create a Google Universal Analytics Tag.

– Insert Tracking ID

– Track Type: Page View

– Expand More settings, Fields to set:

Tags GTM

page : {{virtualPageUrl}}

title: {{virtualPageTitle}}

–  Select Firing Trigger to “Virtual Page View Trigger“.


Save and Publish.

Check Google Analytics Real-time Content Dashboard for the triggered page views now.