Suzanne asks, “How do you get Google Analytics to show you the name of the pdf being clicked on?”
This is a followup to my February 20th video on tracking PDFs as goals in Google Analytics. The short answer is that we have to create a pageview using Google Tag Manager with the built-in Click URL variable and a virtual pageview. Watch the video for a walkthrough.
Can’t see anything? Watch it on YouTube here.
Listen to the audio here:
- Got a question for You Ask, I’ll Answer? Submit it here!
- Subscribe to my weekly newsletter for more useful marketing tips.
- Find older episodes of You Ask, I Answer on my YouTube channel.
- Need help with your company’s data and analytics? Let me know!
- Join my free Slack group for marketers interested in analytics!
What follows is an AI-generated transcript. The transcript may contain errors and is not a substitute for watching the video.
In today’s episode Suzanne asks, How do you get Google Analytics to show you the name of the PDF being clicked on? This is a follow up question to my favorite 20th 2019 video on tracking PDFs as goals and Google Analytics, if you want to go back into the archives, you can go to the blog post that goes with this will have a link to that old episode.
The short answer is to track PDFs as like any other page on your website, we have to create a page view because a PDF contains no HTML, therefore, you can’t put a Google Analytics tag in it, but we can track the click through it.
So in Google Tag Manager, the way to do this is with a built in click URL variable and a virtual page you so let’s, uh, let’s swap over here.
What we’re going to do is you’re going to open up your Google Tag Manager.
The first thing we need to do is make sure that we have we’re tracking click URLs.
That’s one of the many many many Built in variables, so go to variables, click on configure for built ins, and scroll down until you get to the click section.
Personally, I like to make sure that all these are clicks just as a general best practice.
But at the very least, you want to absolutely make sure that click URL is turned on.
And for good measure, by the way, you should always have your Google Analytics set in here as a variable as well, just to make sure that you’re not miss typing the ID number later on.
Next, you’re going to need a trigger.
That trigger for a PDF should be a the trigger type is just links, click just links, right? Like so.
And we want the click URL, which is what we just selected and variables to match the regular expression ignoring case of backslash dot PDF.
Now what this is doing is it’s saying that we want to find any URL that has the dot PDF, extend We escaped the period because we’re using a regular expression, which is a type of code that allows you to match multiple variations.
And the reason we’re choosing this instead of contains is that if you got a bigger website, sometimes people name files like a capital dot PDF at the end, or, you know, or capitalist the P or whatever the case is people do some strange things on larger websites.
And as a result, you would use this to track it.
Now, if you are confident, because it’s your website, maybe it’s a smaller site that no one ever does that, then you could just use contains remove that backslash and contains dot PDF.
So we’re tracking any URL that contains that dot PDF.
This is a trigger, essentially saying, Google Tag Manager listen for this and raise your hand when this happens.
I’m going to because my websites a little older, and sometimes I do weird things.
I’m going to leave it as that match regular expression.
Okay, so now we’ve got a variable that is going to say store a URL in its entirety when it’s when it has that that, that click URL, whatever the click is, we’ve got a trigger that says, I want to run this only on things on the URLs that contain dot PDF.
So last thing we need to do now is set up that tag.
In order to just send the actual information to Google Analytics.
We have not done that yet.
We’re going to create a new tag, what’s called the something intelligible Google Analytics PDF, virtual page view.
Our tag configuration, we’re going to be using the Google Analytics Universal Analytics here.
We’re going to be doing a settings variable here.
Make sure we have our that’s my tag there.
We’re going to make sure we have a page view setup because that’s what we’re setting and then we’re going to go down here to advanced settings.
And in advanced settings, enable overrides.
We’re going to do a field to set we’re going to override our normal variable.
I’m going to choose in this case, the built in Google Analytics very well page.
Right? That is, that is the page URL that Google Analytics is looking for.
And in that, in this case, we are going to you do use that click URL variable.
Right, so now, we’ve got a click URL for sending as a page here, and what the trigger we’re going to choose is, of course, the PDF click.
So now what we’ve done is we’re saying Google Analytics, we’re overriding the normal settings.
And we’re saying, hey, this link clicks That we’re sending that we know a user clicked on is actually a page view, right? You treat it the same as though that PDF was a page on the website and track it as such.
So we’re essentially sending in, in some ways, it’s not falsified data.
But it’s not.
It’s not real in the sense that there’s no Google Analytics tag running on that PDF page.
But hit Save here.
What this is going to do is it will now create page views on in our Google Analytics tracking will always remember to hit submit.
It will create page views in Google Analytics with those that full URL, including the PDF itself, so to Suzanne’s question that will show you the name of the PDF in your analytics.
Now, that means it’ll show up in your behavior section on what content on your site has gotten the most pays us because each of these PDFs will show As it page, and this page using can see, which is the most popular PDF.
This does not set a PDF as a goal, right, that’s go back to the February 20 video for that.
But this does set it as a patient’s probably a pretty good idea to have this implemented on your website, if you’ve got a lot of PDFs, the steps we just took, by the way, apply to any file type.
So if I go back to my workspace here, we have a PDF, click with that regex if you got an mp3 and say you have a podcast and you want to track links to podcast episodes, make an mp3 Click URL and repeat the exact same process.
If you got video files for some strange reason stored on your website, if you have code samples, if you got, you know, JSON or or PHP or our code that you want to see people downloading it, you do the exact same thing.
So you can track multiple different types of files on your website with this technique.
So that’s how you do it.
It’s very straightforward.
It’s not obvious like it’s not written down in the manual anywhere.
But it is a pretty straightforward process once you implement it.
So that’s the process.
Tag Manager, Google Tag Manager is one of the most powerful and underused and underrated tools, I would say in the entire Google marketing platform.
We spend so much time on Google Analytics rightly so because that’s where the outputs come to make decisions.
But what you can do with Tag Manager is fascinating.
So if you have some time, you know, when, when when it’s quiet, or where you have a few moments, spend some time Tag Manager spend a lot of time and tech manager learning capabilities because it’s pretty darn cool.
As always, please have questions in the questions box below.
Subscribe to the YouTube channel on the newsletter, I’ll talk to you soon take care what helps solving your company’s data analytics and digital marketing problems.
This is TrustInsights.ai dot AI and let us know how we can help you
You might also enjoy:
- Best Practices for Public Speaking Pages
- How to Set Your Public Speaking Fee
- How To Start Your Public Speaking Career
- What's the difference between social media and new media?
- Almost Timely: The 2020 Essays
Want to read more like this from Christopher Penn? Get updates here:
Get your copy of AI For Marketers