After adding the Personalization Capture template to your Google Tag Manager workspace you can capture various page events in Personalization.
For an explanation of Google Tag Manager configuration, see Tags, triggers, variables, and the data layer.
Create the event to track in Personalization
Build an event used for tracking purposes. The following example uses an event labeled Add to Cart.
- Create an event.
- Enter values in the following fields:
- Event Name: Example value: Add to Cart
- Event ID: Enter the machine name for the Event Name such as
add_to_cart
. - Customer Site: Click Global.
- Event Type: Click Other.
- Click Save to save the event.
(Optional) Create metadata about the event being captured in Personalization
To map more metadata about the event, you must add column metadata for the event to Personalization. The following example captures the name of the product added as part of the Add to Cart event.
- Follow the instructions for Using column meta data.
- For the column metadata, use the following values:
- Display Name:
Product Name
- Display Order:
1
- Table:
Event
, for the Event table. - Accessor:
custom_field_1(getCustomField1)
(ensure you note the number for the field) - Type:
String
- Description:
Product name from Add to Cart
- Display Name:
Create the tag in Google Tag Manager
- Sign in to Google Tag Manager.
- Create a new tag titled Personalization - Event - Add to Cart.
- In the tag configuration select the Personalization Capture custom template as your tag type.
- In the Capture Type menu, select Event.
- Enter
add_to_cart
as the Event ID. Ensure the Event ID matches the Event ID value generated in Personalization. - To capture the product name in Personalization, map the product name dataLayer variable to the column metadata field (event_udf1) created earlier. In the Event Custom Parameters section, enter the values:
- Parameter name:
event_udf1
- Parameter value:
{{product-name}}
- Parameter name:
After configuring the tag, you can create a new trigger or select an existing trigger. The following example, creates a new trigger from a form fill.
For more information on creating a new trigger in Google Tag Manager, see About triggers
- Once the fields are mapped and have a trigger set, click Save to save the tag.
The tag will now capture any Add to Cart
event on the page the name of the product added to the cart.