GTM
Pushes each tracking event to window.dataLayer and window.NextDataLayer in the 0.4.x format, for GTM containers and forwarders built on it. The format is deprecated, and still sent; new code listens with next.analytics.on. Vendor docs: Elevar data layer.
Config
On by default. Off, pushes still reach window.NextDataLayer but not window.dataLayer:
<script>
window.nextConfig = {
analytics: {
destinations: { gtm: { enabled: false } },
},
};
</script>The 0.4.x analytics.providers.gtm.enabled: false does the same.
What loads
Nothing of its own: the analytics chunk pushes. The SDK never loads GTM: the container is the page's own tag.
Events
dl_add_to_cart and dl_remove_from_cart are pushed once per burst of lines, where product_added_to_cart comes once per line; dl_add_shipping_info once per checkout, for the first of its two tracking events; dl_purchase once per order, once it is paid.
Where pushes go
window.NextDataLayerTransformFn(event), when the page defines it, gets each push first and returns the push to send. A falsy return drops it; an error logs and drops it.- The push goes to
window.NextDataLayer. - Then to
window.dataLayer, after{ ecommerce: null }so GTM clears the previous ecommerce object.
A container built on the tracking names instead pushes them from a listener, with { ecommerce: null } first when it sends an ecommerce object. Turn the dl_* pushes off then, or the container gets each event twice:
next.analytics.on('*', ({ event_type, event_id, data }) => {
window.dataLayer.push({ event: event_type, event_id, ...data });
});The exit-intent popup of next.exitIntent() pushes dl_view_promotion and dl_select_promotion like any promotion, and the five dl_exit_intent_* pushes below, which have no tracking event. A close after a click, or the page removing the popup, sends neither _dismissed nor _closed.
Every push carries the fields of DataLayerPush. The examples show them on dl_user_data; the others leave them out but event and event_id.
dl_user_data
Every page load, with the cart. See the Elevar reference.
From page_viewed.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
cart_total | string | The cart's total, as the API priced it. |
ecommerce | DataLayerEcommerce |
{
"event": "dl_user_data",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"event_time": "2026-11-04T08:30:00.000Z",
"user_properties": {
"visitor_type": "guest"
},
"page_location": "http://localhost:3000/",
"page_title": "Olympus Earbuds",
"page_referrer": "",
"campaign_id": "1310",
"campaign_name": "Olympus",
"campaign_currency": "USD",
"campaign_language": "en",
"campaign_api_key": "pk_test",
"campaign_session_id": "0b8f3c2d1e4a4f6b9c7d5e3f2a1b0c9d",
"attribution": {
"funnel": "Olympus",
"metadata": {
"landing_page": "",
"referrer": "",
"device": "",
"device_type": "desktop",
"fb_fbp": "",
"fb_fbc": "",
"domain": "",
"fb_pixel_id": "",
"sdk_version": "1.0.0",
"conversion_timestamp": 1793781000000
}
},
"_metadata": {
"source": "NextDataLayer",
"version": "1.0.0"
},
"cart_total": "0",
"ecommerce": {
"currency": "USD",
"value": 0,
"items": []
}
}dl_view_item
The page shows one package. See the Elevar reference.
From product_viewed.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
ecommerce | DataLayerEcommerce |
{
"event": "dl_view_item",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"currency": "USD",
"value": 49,
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
}
]
}
}dl_view_item_list
The page shows more than one package. See the Elevar reference.
From product_list_viewed.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
ecommerce | Omit<DataLayerEcommerce, "value"> & { item_list_id: "product_list"; item_list_name: "Product List" } |
{
"event": "dl_view_item_list",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"currency": "USD",
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
},
{
"item_id": "12",
"item_name": "Earbuds ×2",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/2.png",
"price": 44.5,
"discount": 54.5,
"quantity": 2,
"currency": "USD",
"index": 1
}
],
"item_list_id": "product_list",
"item_list_name": "Product List"
}
}dl_add_to_cart
Lines added to the cart, one push per burst. See the Elevar reference.
From product_added_to_cart.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
ecommerce | DataLayerEcommerce | |
first_in_session | boolean | No package was added in this tab before. |
{
"event": "dl_add_to_cart",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"currency": "USD",
"value": 49,
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
}
]
},
"first_in_session": true
}dl_remove_from_cart
Lines removed from the cart, one push per burst. See the Elevar reference.
From product_removed_from_cart.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
ecommerce | DataLayerEcommerce |
{
"event": "dl_remove_from_cart",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"currency": "USD",
"value": 49,
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
}
]
}
}dl_cart_updated
The cart after a price update. Not an Elevar event. See the Elevar reference.
From cart_updated.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
cart_total | string | |
ecommerce | DataLayerEcommerce | |
cart | object | The 0.4.x cart summary. |
cart.currency | string | |
cart.items | { package_id: number; quantity: number; price: number }[] | |
cart.items[].package_id | number | |
cart.items[].quantity | number | |
cart.items[].price | number | |
cart.total_items | number | Σ quantity. |
cart.total_value | number | Σ price × quantity. |
{
"event": "dl_cart_updated",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"cart_total": "49.00",
"ecommerce": {
"currency": "USD",
"value": 49,
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
}
],
"shipping": 0
},
"cart": {
"currency": "USD",
"items": [
{
"package_id": 1,
"quantity": 1,
"price": 49
}
],
"total_items": 1,
"total_value": 49
}
}dl_begin_checkout
The checkout started. See the Elevar reference.
From checkout_started.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
cart_total | string | |
ecommerce | DataLayerEcommerce |
{
"event": "dl_begin_checkout",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"cart_total": "49.00",
"ecommerce": {
"currency": "USD",
"value": 49,
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
}
],
"shipping": 0
}
}dl_generate_lead
The contact details saved an Open Cart. Not an Elevar event. See the Elevar reference.
From checkout_contact_info_submitted.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
currency | string | |
value | number | |
lead_source | "checkout" |
{
"event": "dl_generate_lead",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"currency": "USD",
"value": 49,
"lead_source": "checkout"
}dl_add_shipping_info
Once per checkout: the first of a valid shipping address and a picked shipping method. See the Elevar reference.
From checkout_shipping_address_submitted, checkout_shipping_method_submitted.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
ecommerce | DataLayerEcommerce & { currencyCode: string; shipping_tier: string } | |
event_category | "ecommerce" | |
event_value | number | The cart's total. |
shipping_tier | string | The shipping method's name, else Standard. |
{
"event": "dl_add_shipping_info",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"currency": "USD",
"value": 49,
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
}
],
"shipping": 0,
"currencyCode": "USD",
"shipping_tier": "Standard"
},
"event_category": "ecommerce",
"event_value": 49,
"shipping_tier": "Standard"
}dl_add_payment_info
A checkout submit passed its checks. See the Elevar reference.
From checkout_payment_info_submitted.
The fields of DataLayerPush, and:
| Field | Type | Present | |
|---|---|---|---|
ecommerce | DataLayerEcommerce & { payment_type?: string } | always | |
event_category | "ecommerce" | always | |
event_value | number | always | The cart's total. |
payment_type | string | optional | Credit Card for a card, else the payment method; none before one is picked. |
{
"event": "dl_add_payment_info",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"currency": "USD",
"value": 49,
"items": [
{
"item_id": "11",
"item_name": "Earbuds ×1",
"item_category": "Olympus",
"item_product_id": "400",
"item_image": "https://cdn.test/1.png",
"price": 49,
"discount": 50,
"quantity": 1,
"currency": "USD",
"index": 0
}
],
"shipping": 0,
"payment_type": "Credit Card"
},
"event_category": "ecommerce",
"event_value": 49,
"payment_type": "Credit Card"
}dl_purchase
An order was paid, without its upsells. See the Elevar reference.
From checkout_completed.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
pageType | "purchase" | |
ecommerce | DataLayerPurchase |
{
"event": "dl_purchase",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"pageType": "purchase",
"ecommerce": {
"currency": "USD",
"transaction_id": "1001",
"value": 89,
"tax": 7.12,
"shipping": 9.99,
"affiliation": "Online Store",
"items": [
{
"item_id": "EB-2",
"item_name": "Earbuds",
"item_brand": "Olympus",
"item_category": "Olympus",
"item_sku": "EB-2",
"item_image": "https://img.test/eb.png",
"price": 44.5,
"quantity": 2,
"currency": "USD",
"index": 0
}
]
}
}dl_upsell_purchase
One upsell was accepted. Not an Elevar event. See the Elevar reference.
From upsell_completed.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
pageType | "upsell" | |
ecommerce | DataLayerPurchase | |
upsell_metadata | object | |
upsell_metadata.original_order_id | string | The order's ref_id. |
upsell_metadata.upsell_number | number | 1 for the first upsell on the order. |
upsell_metadata.package_id | string | |
upsell_metadata.package_name | string |
{
"event": "dl_upsell_purchase",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"pageType": "upsell",
"ecommerce": {
"currency": "USD",
"transaction_id": "R1-US1",
"value": 20,
"tax": 0,
"shipping": 0,
"affiliation": "Upsell",
"items": [
{
"item_id": "SKU-99",
"item_name": "Bump",
"item_brand": "Olympus",
"item_category": "Olympus",
"price": 20,
"quantity": 1,
"currency": "USD",
"index": 0
}
]
},
"upsell_metadata": {
"original_order_id": "R1",
"upsell_number": 1,
"package_id": "99",
"package_name": "Bump"
}
}dl_viewed_upsell
An upsell page showed an offer. Not an Elevar event. See the Elevar reference.
From upsell_viewed.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
order_id | string | The order's ref_id. |
page_path | string | |
upsell | object | |
upsell.package_id | "page_view" | |
upsell.package_name | "Upsell Page View" | |
upsell.currency | string |
{
"event": "dl_viewed_upsell",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"order_id": "R1",
"page_path": "/upsell/",
"upsell": {
"package_id": "page_view",
"package_name": "Upsell Page View",
"currency": "USD"
}
}dl_skipped_upsell
An upsell was skipped. Not an Elevar event. See the Elevar reference.
From upsell_skipped.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
order_id | string | The order's ref_id. |
upsell | object | The first package offered; unknown when there was none. |
upsell.package_id | string | |
upsell.package_name | string |
{
"event": "dl_skipped_upsell",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"order_id": "R1",
"upsell": {
"package_id": "3",
"package_name": "Earbuds case"
}
}dl_view_promotion
A promotion was shown. Not an Elevar event. See the Elevar reference.
From promotion_viewed.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
ecommerce | DataLayerPromotion |
{
"event": "dl_view_promotion",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"promotion_id": "exit_intent",
"promotion_name": "Exit offer",
"creative_name": "exit-offer"
}
}dl_select_promotion
A promotion was clicked. Not an Elevar event. See the Elevar reference.
From promotion_selected.
The fields of DataLayerPush, and:
| Field | Type | |
|---|---|---|
ecommerce | DataLayerPromotion |
{
"event": "dl_select_promotion",
"event_id": "3f2b8c1d9e7a4b6c8d5e2f1a0b9c8d7e",
"ecommerce": {
"promotion_id": "exit_intent",
"promotion_name": "Exit offer",
"creative_name": "exit-offer"
}
}dl_exit_intent_shown
The exit-intent popup opened. It has no tracking event. See the Elevar reference.
The fields of DataLayerPush and DataLayerExitIntent, and:
| Field | Type | |
|---|---|---|
exit_intent | DataLayerPopup |
dl_exit_intent_accepted
The exit-intent popup's image was clicked. It has no tracking event. See the Elevar reference.
The fields of DataLayerPush and DataLayerExitIntent, and:
| Field | Type | |
|---|---|---|
exit_intent | DataLayerPopup |
dl_exit_intent_action
A close or apply-coupon button of the exit-intent popup, or a custom action once it has run. It has no tracking event. See the Elevar reference.
The fields of DataLayerPush and DataLayerExitIntent, and:
| Field | Type | |
|---|---|---|
exit_intent | object | close, apply-coupon or custom, with the code an apply-coupon button applied. |
exit_intent.action | string | |
exit_intent.coupon_code | string |
dl_exit_intent_dismissed
Esc or the overlay closed the exit-intent popup. It has no tracking event. See the Elevar reference.
The fields of DataLayerPush and DataLayerExitIntent, and:
| Field | Type | |
|---|---|---|
exit_intent | DataLayerPopup |
dl_exit_intent_closed
The exit-intent popup's × button closed it. It has no tracking event. See the Elevar reference.
The fields of DataLayerPush and DataLayerExitIntent, and:
| Field | Type | |
|---|---|---|
exit_intent | DataLayerPopup |
Types
DataLayerPush
The fields every dl_* push carries, in the 0.4.x Elevar format.
| Field | Type | Present | |
|---|---|---|---|
event | string | always | The dl_* name. |
event_id | string | always | The tracking event's event_id; the transaction id on dl_purchase and dl_upsell_purchase. |
event_time | string | always | Its ISO time. |
user_properties | object | always | In the Elevar format. |
user_properties.visitor_type | "guest" | always | |
page_location | string | always | The page, without the query string. |
page_title | string | always | |
page_referrer | string | always | |
campaign_id | string | optional | The campaign, at the top level as 0.4.30 sent it. |
campaign_name | string | optional | |
campaign_currency | string | optional | ISO 4217, such as USD. |
campaign_language | string | optional | |
campaign_api_key | string | always | The campaign's public API key. |
campaign_session_id | string | always | |
attribution | Attribution | always | UTM parameters, affiliate and click ids, landing page; URLs in metadata without their query string. |
_metadata | object | always | |
_metadata.source | "NextDataLayer" | always | |
_metadata.version | string | always |
DataLayerEcommerce
A push's ecommerce, GA4-style.
| Field | Type | Present | |
|---|---|---|---|
currency | string | always | ISO 4217, such as USD. |
value | number | always | Σ price × quantity of items. |
items | DataLayerItem[] | always | |
coupon | string | optional | The first code on the cart. |
shipping | number | optional | The shipping method's price, once one is picked. |
DataLayerPurchase
A paid order, or one accepted upsell, as ecommerce.
| Field | Type | Present | |
|---|---|---|---|
currency | string | always | |
transaction_id | string | always | The push's event_id. |
value | number | always | Σ price × quantity of items. |
tax | number | always | 0 on an upsell. |
shipping | number | always | 0 on an upsell. |
affiliation | "Upsell" | "Online Store" | always | |
items | DataLayerItem[] | always | The order's lines without its upsells, or the upsell's one line. |
coupon | string | optional | The code the order was placed with. |
discount | number | optional | The order's total discount, when above 0. |
DataLayerPromotion
A promotion push's ecommerce.
| Field | Type | Present | |
|---|---|---|---|
promotion_id | string | always | |
promotion_name | string | optional | |
creative_name | string | optional |
DataLayerExitIntent
The fields of an exit-intent popup's push.
| Field | Type | |
|---|---|---|
event_category | "engagement" | |
event_action | string | exit_intent_<moment>, or exit_intent_<button action> on dl_exit_intent_action. |
event_label | string | The popup's image URL, else its template; the coupon code or button action on dl_exit_intent_action. |
DataLayerPopup
An exit-intent popup, as its pushes describe it.
| Field | Type | |
|---|---|---|
image_url | string | Its image URL, else empty. |
template | string | Its template, else empty. |
DataLayerItem
One product of a push's ecommerce.items, GA4-style.
| Field | Type | Present | |
|---|---|---|---|
item_id | string | always | The SKU, else the package's external id; SKU-<product id> on an order line without one. |
item_name | string | always | |
item_brand | string | optional | The product name, else the campaign name; order lines only. |
item_category | string | optional | The campaign name. |
item_variant | string | optional | |
item_product_id | string | optional | |
item_variant_id | string | optional | |
item_sku | string | optional | |
item_image | string | optional | |
price | number | always | What one unit costs, after discounts. |
discount | number | optional | The discount on one unit, when there is one. |
quantity | number | always | In units: a package of 2 added once is 2. |
currency | string | always | ISO 4217, such as USD. |
index | number | always | Position in items, from 0. |