Google Analytics 4 and GTM
The GA4 integration works by automatically sending events to GA4.
The following events are sent:
For widgets: widget_view - for widget views
widget_click - for widget clicks
widget_submit - for widget submits
With the following parameters:
{ widget_id, widget_name, variation_id, variation_name, experiment_id, control }
For campaigns: campaign_view - for campaign views
With the following parameters:
{ campaign_name, control, variation_id, variation_name }
Google Tag Manager
If your Google Analytics tag is configured via GTM, you'll need to make additional adjustments to make sure the events are relayed to Google Analytics.
Create a trigger
Go to your Container.
- Go to Triggers
- Click New
- In the form
- Name the trigger, for example, "Personizely event"
- Event name - (widget|campaign)_.*
- Check the "Use regex matching" checkbox
- Set the "This trigger fires on" to "All Custom Events"
- Save
Create an event tag
- Go to Tags
- Click New
- Tag Configuration
- Select Tag type - "Google Analytics: GA4 Event"
- In the form:
- Measurement ID - the ID of your measurement, which looks like "G-XXXXXXXX"
- Event name - {{Event}}
- Events Parameters
Add the following parameter-value pairs:
- widget_id - {{Widget ID}} (create a new variable with the variable name Widget ID and Data Layer Variable Name - widget_id)
- widget_name - {{Widget Name}} (create a new variable with the variable name Widget Name and Data Layer Variable Name - widget_name)
- experiment_id - {{Experiment ID}} (create a new variable with the variable name Experiment ID and Data Layer Variable Name - experiment_id)
- control - {{Control}} (create a new variable with the variable name Control and Data Layer Variable Name - control)
- campaign_name - {{Campaign Name}} (create a new variable with the variable name Campaign Name and Data Layer Variable Name - campaign_name)
- variation_id - {{Variation ID}} (create a new variable with the variable name Variation ID and Data Layer Variable Name - variation_id)
- variation_name - {{Variation Name}} (create a new variable with the variable name Variation Name and Data Layer Variation Name - variation_name)
For each parameter, create a new Data Layer Variable:
- Start typing "{{" in the value field
- Select New variable at the end
- Select the type to be "Data Layer Variable", and then specify the respective name and Data Layer Variable Name (see the part between parentheses for each parameter).
- Triggering
- Select the trigger you have created in the first step (Personizely event).
- Save
The campaign_id parameter was dropped because it conflicts with GA4's own campaign_id, which refers to the UTM Campaign ID. Please rely on campaign_name.
Submit
Now you can submit your container, and Personizely events will be automatically relayed to Google Analytics. The same method can be used to send Personizely events to any other tags you have in GTM.
⚠️ Important Before Personizely can send events to Google Analytics, you must enable the integration in the Personizely Dashboard. Go to Settings → Integrations, then click Enable next to Google Analytics. Once enabled, events will be automatically sent to Google Analytics.