Tracking Downloads as Virtual Page Views in Google Analytics using Google Tag Manager

If you have any downloadable assets such as PDFs, word doc, etc. on your site, then by default, Google Analytics can not track how many people downloaded those assets.  To track them, you can track them as events or page views (known as virtual page views since they are not actual page views).

Let’s look at how to track them as virtual page views. The trigger that we will create can also be used to trigger an Event tag if you decide to track them as events.

Below, is an example page that has links to download a PDF and a word document.

Figure: Downloads as Virtual Page Views

Configuring the Trigger

Let’s create a Trigger first by following the steps below

  1. 1. Create a new trigger
  2. 2. Trigger Type: In this case, the downloads are links, so in the trigger type, select “Just Links”.
  3. 3. Since we don’t want any link to be tracked, we want specific links, i.e. the links that either have .docx, .doc, .pdf or xlsx at the end. You can use whatever extension your downloadable extensions have. To create this trigger click on “Some Link Clicks”
  4. 4. Next, your click filter criteria are based on the URL of the link, so pick “Click URL”
  5. 5. Next, select the “matches RegEx”, RegEx allows you to match a pattern. (Full details of RegEx are beyond the scope of this book).
  6. 6. Next, you select the pattern that you want to look at. This is where you can enter docx, xlxs, pdf, etc. To separate different patterns, you use a pipe character (|), which means OR condition. The final pattern will be pdf|docx|doc|xlsx

Figure: Download Trigger

  1. 1. Now, give the trigger a name. I called it “Download Clicks”, and then save it.

Next, we will create the Tag

Configuring the Tag

Let’s create a tag that will track these clicks as virtual page views in Google Analytics.

  1. 1. Click on New Tag
  2. 2. Select Universal analytics since we will track them in Google Analytics
  3. 3. Set your Google Analytics tracking ID, as we did before.
  4. 4. Next, select “Enable overriding settings in this tag”.
  5. 5. Click on More Settings.
  6. 6. Click on Fields to Set.  This is where we will set the field name “page” with the value we want to set when a user clicks on the download link.
  7. 7. Click on “Add Field”, you will see many variables that can we used in this field. What we need is the page, so type in “page” (without double quotes). The page should appear as one of the options in the dropdown.
  8. 8. Next, let’s give the page that we want to see in the Pages report in Google Analytics.  To identify the virtual page views, choose an identifier that will tell you that the page in a virtual page. I am going to use /download/ in front of the link name. So the final value is /download/{{Click URL}}, since {{Click URL}} is the in-built variable that tracks the URL of the link that was clicked. You can use any other variables such as {{Click Text}} etc. that you would like to see in the reports. To see all the available options, you can click on the + sign next to the field. (Note: if the built-in variable is not available then you will have to configure them by clicking on the “Built-in” link on the top right-hand side of the Variable window.
  9. 9. Give your tag a name and save it.

Figure: Download Tag

Make sure you attach the previously built Trigger to this tag. Save it and preview before publishing.

You will now start to see the virtual page views in your report, as shown below.


Want to Learn Google Tag Manager. Here are few options:

  1. Get Google Tag Manager Book at Amazon
  2. Signup for Google Tag Manager Course on Udemy
  3. Signup for Optizent Academy and get Google Tag Manager + 20 other courses
  4. Free Introduction to Google Tag Manager course

Leave a Reply

Your email address will not be published. Required fields are marked *