Google Tag Manager (GTM) Relies on a global array (window.dataLayer) to push event objects to and process them from. GTM listens to this array for events and reacts to each event. For example, after an add to cart event on a website a snapshot of the data layer may look as follows...
window.dataLayer = [
{ event: "gtm.dom", ... }, // user loads a page
{ event: "dl_view_item", ... }, // user views a product
{ event: "dl_add_to_cart", ... }, // user adds a product
...
];
// Pushing a new event into the data layer
window.dataLayer.push({ event: "dl_remove_from_cart", ... });
Some of these events are automatically pushed to the data layer by GTM. What you’ll need to implement and push into the data layer at the correct times are the following events:
dl_user_data
: The base event that should be fired before any other event, and on all virtual page changes.dl_sign_up
: When a user signup occurs. If account management is handled on Shopify’s online store and not on the headless site, then this event can be disregarded.dl_login
: When a user logs in. If account management is handled on Shopify’s online store and not on the headless site, then this event can be disregarded.dl_view_item_list
: Collection/Product Listing pageview.dl_view_search_results
: Search results pageview.dl_select_item
: Item clicked from collection or search page.dl_view_item
: Item view.dl_add_to_cart
: Add to cart.