Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Add dataLayer events

Learn how to setup custom datalayer events

1. build the dataLayer events

AdPage follows the Google Tag Manager dataLayer standard. Learn more about event structure in the Google documentation.

The following events are important for an eCommerce website:

Note: These events are a guide for eCommerce websites. Custom events or other website goals, such as lead generation, may require different events.

Prefix events with trytagging_ to avoid conflicts with existing dataLayer events.

2. Add the user_data datalayer event

The user_data event is the first event sent on your website. Add it before other dataLayer events. It acts as the Google Tag Manager start signal. Tracking data may not arrive correctly without it.

When using webhooks, each page must override client_id, session_id, and session_count with Google-generated IDs. Trigger the Google tag from the dataLayer user_data event. Trigger every other event only after the Google tag.

The user_data event requires an additional script. Add this script to the <body>:

Note: Find the connected domain in the installation link. You can also find it under Implementation → Domain name in the AdPage Tagging dashboard. Update the URL for each domain.

This script provides two JavaScript helper functions:

Then send the first user_data event in JavaScript:

Add marketing to every subsequent event. This is an example view_item event:

2.1 Optional wait for the user_data script

We recommend loading the user_data script with defer. This prioritizes other critical page elements. It also means the script may not be immediately available.

The user_data script sends a custom JavaScript event when its functionality becomes available. Use that event as follows:

Last updated

Was this helpful?