add google tag manager with download data event tracking #581
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
For issues:
Notes
This new setup requires some orchestration between the new-ish Google Tag Manager console and the familiar Google Analytics console. It took more time than expected to figure it out, but I understand it now (somewhat). GTM provides non-technical users a way to setup Google Analytics event tracking within the GTM admin console, without making any code changes.
Google Tag Manager console
I followed this guide to implement the click tracking.
In the Google Tag Management console, I created two triggers:
Download Source Data Event
Download Standardized Data Event
Both of these triggers are attached to the same
Download Data Event Tag
.Google Analytics console
When a user clicks on either of the links for the triggers, it will log in Google Analytics with the
download_data_event
.BGA users will be able to distinguish between the download triggers (standardized data vs source data) with the help of values in
download_data_text
anddownload_data_url
. We can separate these two triggers to have their own tags if we want, but for this iteration all download events are tagged as adownload_data_event
.Note that the Google Tag Manager in GA4 tracks file downloads by default. I turned this off since I thought it would be confusing to have two different file download event types, and decided to consolidate under this one custom
download_data_event
. Also, the source file was the only download tracked by this, since the new data download requests the server and doesn't have a filename (which is used by GA4 to determine if it's a file_download event)Testing
git pull origin google-tag-manager
.Salary
property in Google Analyticsdownload_data_event
type. Apparently it takes some time for the events to show up in the Engagement section.