Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
How to track PDF downloads as pageviews
1. Degordian
TRACKING PDF
DOWNLOADS AS
PAGEVIEWS
by Robert Petković, Google Analytics Specialist
07.10.2014.
2. TRACKING PDF DOWNLOADS AS PAGEVIEWS
• Google Analytics is able to track PDF
downloads
• You can track PDF downloads as Google
Analytics Events or Virtual Pageviews
• We recommend to track it as Virtual
Pageviews
3. THE EVENT LISTENER TAG
• The Event Listener tag - “code” that you use for
listening to what is going on on your web page(s)
• Few different types of event listeners are available
• For tracking PDF downloads as pageviews you should
use the link click listener
• It fires every time a user clicks to an anchor link
• Learn more at Google Tag Manager help
4. HOW TO SET UP THE EVENT LISTENER TAG?
STEP 1
• Firstly create one new Tag for that event
listener
• Under “Tag Type” select “Event Listener”
and then choose “Link Click Listener”
• Enable it to trigger on every page by
adding “All Pages” rule to that tag
• Save your tag and you are ready to move
further
5. HOW TO SET UP THE EVENT LISTENER TAG?
STEP 2
• To include clicks to PDF files only
click to “New – Rule”
• Link click listener triggers an reserved
event called gtm.linkClick once you
click on any webpage anchor
• We will first add event that equals (or
contains) “linkClick”
• After that, set up Regular Expression
rule that says “In case this link URL
contains PDF only”
6. HOW TO SET UP THE EVENT LISTENER TAG?
STEP 3
• Create new tag
• Select it’s type to be “Universal Analytics” and
type the appropriate Google Analytics ID
7. HOW TO SET UP THE EVENT LISTENER TAG?
STEP 3
• Under “Document Path” you should
put the PDF document file name
• Don’t forget to fire this tag on PDF
links only!
• Under “Tag Rules” select that rule you
created before: “PDF links only”
• Save your tag and voilà!
8. HOW TO SET UP THE EVENT LISTENER TAG?
STEP 4
• Create new Tag Manager container version
• Publish it
• Your website will immediately start sending the proper PDF download information
to Google Analytics
• You can see the full URL of that document under “Behaviour”‘ section
9. HOW TO SET UP THE EVENT LISTENER TAG?
STEP 5
• If other Pageviews’ URLs doesn’t
start with “http://” but with a slash
only, there is simple solution
• Create one macro that returns only
the portion of the URL after the
domain name
• Its type should be “Auto-event
Variable” with Variable Type of
“Element URL” and (very
important!) a Component Type
“Path”
• Save that macro
10. HOW TO SET UP THE EVENT LISTENER TAG?
STEP 5b
• Now go back to the “PDF virtual
Pageviews” tag you created earlier
• Take a look at its Basic
configuration
• Replace the existing “Document
Path” value with the macro you just
created: “element path”
• That’s it!
11. TRACKING PDF DOWNLOADS AS PAGEVIEWS
• Google Tag Manager is getting text via macro called “element text”
• That’s the actual macro value you should put under “Document Title”
• Save the tag, create and publish new container version and now you
have PDF documents with URL and title in your Google Analytics
reports!
12. TRACKING PDF DOWNLOADS AS PAGEVIEWS
• In the end it should look like this
• For any questions, fell free to contact us