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:
user_data (installed in step 2.1)
view_item_list (Google documentation)
view_item (Google documentation)
add_to_cart (Google documentation)
remove_from_cart (Google documentation)
view_cart (Google documentation)
begin_checkout (Google documentation)
add_payment_info (Google documentation)
add_shipping_info (Google documentation)
purchase (Google documentation)
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.
The user_data event requires an additional script. Add this script to the <body>:
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?

