Track File Downloads In Google Analytics 4 With Custom Events

Jul 27, 2021 | Marketing

A lot of marketers get a bit overwhelmed when trying to migrate their current workflow from Universal GA to the new Google Analytics 4, especially when it comes to custom tracking and custom events. With GA3, event tracking was pretty simple and straightforward, however, GA4 is more open-ended while lacking a lot of official documentation. The catch is that once you understand GA4, its role with Google Ads and Google Tag Manager, you’ll find yourself with many more options than you once had. That said, this quick-start guide will go over custom event tracking within Google Analytics 4, using Google Tag Manager and passing data layer parameters.


Tracking File Downloads With Google Tag Manager and Google Analytics 4

Let’s get right into it and create a trigger in GTM that most are familiar with. Nothing is much different here, but I’ll go over the basics again. Whether it’s a CSV file or a PDF file you want to track, or a .DOCX or maybe a .EXE… the Google Tag Manager setup remains the same.

custom event tracking with GA4 in GTM

Trigger configuration: Some Link Clicks & Click URL

As shown above, our basic trigger is Some Link Clicks, with our Click URL containing “.pdf”. Change the filetype you wish to track based on your file. If there’s multiple feel free to use REGEX or multiple trigger statements per filetype. In this case we’ll make it easy and just track .PDF downloads. For example, I have a very cool eBook on several of my landing pages, and I’d like to remarket to those that viewed my awesome eBook. It’s okay if you have a dozen different eBooks that require a dozen different remarketing segments- we will show you how to segment below.


Setup Your GA4 Event Tag For The Custom Trigger Event

Next step after our trigger is complete is creating our tag. Since we’re focusing on GA4, obviously our tag type will be Google Analytics: GA4 Event. Our configuration tag is our GA4 tracking ID, and in this case I named the event simply “download”. Now, you can expand “Event Parameters” and this is where the fun starts.

With GA4, you can pass numerous parameters for your designated event. You can name your ‘parameter name’ whatever you wish, but your parameter value needs to be something useful. In our case the parameter value is the data layer variable {{Click text}}, which is simply the anchor link of the downloaded PDF. You can add more or change your parameters to be more specific such as Page Title (which page the PDF was downloaded). You can get as granular as needed depending on your marketing campaigns.

We will just be passing over 1 parameter in this guide- we are tracking all PDF file downloads and the file name (anchor text) of that PDF. That will give me enough info to segment my audiences based on what they downloaded.

Setting Up Google Analytics 4 Custom Events From GTM

ga4 custom event setup config

Custom Events in Google Analytics 4

This is where a lot of users often get tripped up. You have to make sure your custom GTM GA4 event is correctly passed to the Google Analytics 4 dashboard. To do this, go to “Configure” and then to “Events”, and click “Create Event”. This will be ‘linking’ your custom event from GTM and the parameters to display correctly in the new Analytics dashboard.

For the custom event name, I made it simple and called it “download”. Our matching conditions will make sure our GTM event is correlated to GA4. The parameter for matching conditions will be the event_name EQUALS, the same event name we made in Google Tag Manager, which is “download”. This will ensure GA4 knows that these are custom events and which event names to look for.

For our parameter configuration, we want to keep it the same as the source event (which is GTM and already defined). So enable “Copy parameters from the source event” and click save.

Testing Our GA4 Custom Event With GTM Preview

If you’d like to do a quick test and make sure everything is working correctly, initiate a preview mode in Tag Manager and click the .PDF (or whatever filetype used). You should see a hit being sent by the name of the tag to GA4. In the above image you can see the hit sent after clicking a pdf document called “document” – success. Now, let’s check out how it appears in GA4 realtime reporting:

GA4 custom event parameters

In Real-time view, we can see our tag fire when clicking a PDF document.

Taking a look at GA4’s real time view, and after a .PDF is clicked, we can take a look at the events and find our tag being fired. We can see the event being reported, now let’s make sure our parameters are being reported correctly. We only did a basic parameter pass in this quick tutorial where we just grabbed the click text (anchor text) of the PDF. Again, feel free to get as granular as needed and add as many parameters as you wish. However, GA4 comes with several built in parameters for all events, such as ‘page title’ and ‘page referrer’.

GA4 custom event parameters

Quick look at the parameters being passed into GA4 from our GTM setup.

And finally, above you can see confirmation of the initial “{{Click text}}” which we passed in the parameters. As you can see, our .PDF anchor text was “download our ebook about GTM!”, and we can see it working correctly from the GA4 real-time view. Our basic setup works, and, in my opinion, is much easier than previous GA / GTM setups.

The GA4 Custom Event Is Passed, Now What?

Depending on what you need to do or accomplish, it’s all up to you. Want to create a segmented audience for this event to remarket to on Google Ads or Facebook Ads? Need to put these users into an email flow that downloaded a specific eBook? All that is possible based on your goals. In this case, our partner wants to build a remarketing list for eBook PDF downloads which supplements their email campaigns. With this setup complete, we can now remarket or followup to potential customers that have downloaded an eBook, without blindly sending remarketing ads with irrelevant info. We know exactly what the customer downloaded which gives us much better insight into how to build out our remarketing flows.

5/5 (2 Reviews)
Alexander Hatala

Alexander Hatala

Co-founder Custom Design Partners

Alexander Hatala is the co-Founder at Custom Design Partners. He specializes in e-Commerce operations, performance marketing strategies, and behavioral analytics.


Submit a Comment

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