Configure Google Analytics 4 Measurement Id
Open your Google Analytics account and navigate to Admin
On the Admin Page, select Data Streams.
In Data Stream, click 'Web' (if you're using Tag Manager on a webpage).
Enter your page URL and name, then click Create Stream.
After clicking Create Stream, a page with a Measurement ID will appear, which you can use in your Google Tag Manager account.
Configure Tag Manager
Create Google Analytics 4 tag
On your Google Tag Manager, navigate to the 'Tags' tab and then click 'New' to proceed.
Name the tag Google Analytics 4 tag, then click Tag Configuration and select Google Tag.
Enter your Measurement ID in the "Tag ID" field (learn more here).
Navigate to "Tag firing options" under "Advanced Settings" and select "Once per page".
Explanation: 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
To ensure that your non-IAB vendor scripts are not triggered without consent, follow these steps to create consent default status variables:
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"