The DataLayer is a structured JavaScript object used to store and manage data on a website, particularly for analytics and tracking purposes. It acts as a bridge between a website and various tracking tools like Google Tag Manager (GTM), Google Analytics, and other third-party services.
How Does the DataLayer Work?
The DataLayer collects and holds information about user interactions, such as page views, purchases, and form submissions. This data is then used by analytics tools to generate insights without relying on direct script injections.
For example, when a user completes a purchase, the DataLayer can store details like:
Ecommerce object
Ecommerce object
{
"ecommerce": {
"purchase": {
"actionField": {
"id": 5987206,
"affiliation": "Online Store",
"revenue": 20.65,
"tax": 3.86,
"shipping": 7.99,
"coupon": "",
"cart_discount": 0,
"discount_label": ""
},
"products": [
{
"name": "Q-Connect Punched Pockets Polypropylene 50 Micron A4 Embossed (100 Pack) KF24001",
"id": "KF24001",
"price": 8.8,
"quantity": 1,
"coupon": "",
"metric1": ""
}
]
}
}
}
User object
User object
{
"email": "joe@freemancontingent.ie",
"name": {
"full_name": "Joe Blogs",
"first_name": "Joe",
"last_name": "Blogs"
},
"phone_number": "",
"address": {
"street": "asdf",
"city": "adsf",
"state": "Carlow",
"country": "IE",
"postcode": "P85FX62"
},
"billing_address": {
"street": "asdf",
"city": "adsf",
"state": "Carlow",
"country": "IE",
"postcode": "P85FX62"
}
}
This structured data can then be accessed by tracking tools via Google Tag Manager to trigger relevant tags and events.
Why Use the DataLayer?
• Security: Reduces reliance on direct third-party JavaScript injections, making data collection safer.
• Flexibility: Centralizes data collection for multiple tools without modifying the website’s core code.
• Efficiency: Improves site performance by minimizing redundant tracking scripts.
Example of a DataLayer Object:
User data on other pages - EvoXLayer
EvoXLayer can be used to get user data on most other pages of the site.
Hope you have a great day! 😀