When it comes to basic event tracking, such as pageviews, Data Layers are usually not needed, built-in GTM variables may suffice.
So, when Data Layers come in handy?
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase',
transaction_id: '12345',
value: 99.99,
currency: 'EUR',
1. items: [{ id: 'sku-1', name: 'Product A', quantity: 1 }]
});
Identify all events and parameters required for your tracking and reporting needs.
Add dataLayer.push()
statements to your site code at the appropriate interaction points (e.g., after a successful checkout).
In GTM, create Data Layer Variables for each parameter you need to access in tags or triggers.
Use Custom Event triggers that listen for specific event values in the Data Layer. Configure tags to fire when these triggers are met.
Use GTM’s Preview Mode and server-side Preview tools to verify that events and parameters are captured and processed as expected.
You can develop a Data Layers manually, but we developed 5 plugins for the most used e-commerce platforms to help you save time.