Custom event destinations
Overview
Contentful Personalization provides several plugins that allow you to send Experience impression events to downstream systems. Reporting on Experiences in analytics systems you adopt is an excellent supplement to Experience Insights.
Google Tag Manager is a popular tool for routing client-side events to your destinations of interest using tags. This guide covers setting up variables, triggers, and tags to receive component impression events.
Set up Google Tag Manager
To track personalized components or measure experiment results, Google Tag Manager (GTM) requires some data from the data layer. Your triggers can then be set up through the values contained in the data layer.
Step 1: Set up Variables
Variables help you send certain information about the Experience that was seen forward via Google Tag Manager.
To set up variables for your website:
- Go to the "Variables" section in your Google Tag Manager and create a new User-Defined variable.
- Give your variable a name (according to your variable base on the next steps).
- Select a variable type. Your variable type should be the
data layer
. - After choosing a variable type, you need to enter a name for the data layer variable field.
- Save your variable.
Step 2: Create an event trigger
An event trigger can be fired every time an Experience was seen.
To set up a trigger for your content:
- Go to the "Triggers" section in your Google Tag Manager and create a new trigger.
- Enter a relevant name.
- Select a trigger type, and choose Custom event.
- Use
nt_experience
as the event name value. - Click Save to save your trigger.
Step 3: Set up a tag to forward your experience trigger
To create a tag:
- Go to the "Tags" section in your Google Tag Manager and create a new Tag.
- Choose your tag type depending on where you want to send your data. For example, if you would like to forward data to Google Analytics, choose "Google Analytics: GA4 Event".
- Enter an event name and event parameters. Here, you can now use the variables that you have set up before.
- As a trigger, use the event trigger that you have previously set up.
- Save your tag.
Repeat step 3 several times if you would like to forward these events to more destinations.
Preview website
You can now preview your website using Google Tag Manager's Preview Mode to see that events are triggered correctly. The trigger and tag that you have set up should now fire every time the user sees an Experience.