Step-by-step guide on setting up a GTM tag for Usercentrics.
Learn how to integrate the Usercentrics CMP with Google Tag Manager to manage consent and ensure compliance with GDPR and other privacy regulations.
This guide explains how to set up GTM tags. In this example, we will use the Google Analytics 4 (GA4) service. However, the same steps can be followed for any service that has been created via a tag in GTM and added to the Usercentrics admin interface under Data Processing Services.
For this example, you will need the Measurement ID from your Google Analytics dashboard.
Create a GA4 Tag
- Open your Google Tag Manager account.
- Go to the Tags section.
-
Click New.
- Name the tag "Google Analytics 4 Tag".
- Click on Tag Configuration and choose select Google Tag.
- Paste your Measurement ID in the Tag ID field. (learn more here).
- Scroll down to Advanced Settings > Tag firing options.
-
Choose Once per page (recommended by Usercentrics).
- Note: If you want a certain technology to fire more than once per page view, you should set the tag firing option to "Unlimited". "Once per page", however, is Usercentrics' recommended setup.
Save "Google Analytics 4 Tag".
Create Google Analytics 4 variable
- Go to "Variables" in the side menu and select "User-Defined Variables," then click "New."
- Choose the variable type as "Data Layer Variable."
- Name the variable “Google Analytics 4 Variable” in the top-left field.
- For "Data Layer Variable Name," enter "Google Analytics 4" (exact spelling, capitalization, and hyphenation are required).
- Check the box for "Set Default Value" and set the default value to false.
- Save the "Google Analytics 4 Variable."
Create a Google Analytics 4 trigger
⚠️ Note: There are several ways to implement this logic. Usercentrics recommends the following option, however, depending on your setup, other structures might be more reasonable.
- Go to "Triggers" in the side menu and click "New."
- Choose "Custom Event" as the trigger type.
- In the top left, name the trigger "Google Analytics 4 Trigger."
- Check "Use regex matching" next to the "Event Name" field.
- In the "Event Name" field, enter
consent_status.*
⚠️ Note: Ensure the spelling, hyphenation, and capitalization are exact.
- Select "Some Custom Events."
- In the condition settings, set: "Google Analytics 4 Variable" contains true. This ensures the trigger only fires if the user has opted in (variable=true).
- Save the trigger as "Google Analytics 4 Trigger."
Finally, add the trigger to the "Google Analytics 4 Tag"