If you are wondering what a Data Layer is, what needs to be done to build one, and how to use it in Adobe Analytics or Google Analytics then this post is for you.
What is a Data Layer?
In simple terms, a data layer is a JavaScript object on your website pages that hold the data that you need to pass from your website to various web analytics, tracking, or tracking tools. Whenever a tool such as Adobe Analytics or Google Analytics needs the data, they can just refer to the dataLayer and pick up the values stored in the data layer.
Let's take an example to clarify it.
Say you are showing the price of the product on your webpage. This price can be simply stored in a dataLayer that might look like this
dataLayer = {
price: "100"
currencyCode: "USD"
}
This is a very simple structure of the dataLayer. DataLayer can be complicated depending on the values that you want to store.
Here is another example of dataLayer. In this dataLayer we are storing information about two products that the end-user is looking for on that particular page, where this dataLayer is coded.
------------------------------------------------------------
<script> dataLayer ({ 'ecommerce': { 'currencyCode': 'USD', 'product': [ { 'name': 'Blue Shirt', 'id': '55567', 'price': '15.25', 'brand': 'Optizent', 'category': 'Apparel' }, { 'name': 'Red Shirt', 'id': '55568', 'price': '30.00', 'brand': 'Optizent', 'category': 'Apparel' }] } }); </script>
----------------------------------------------------------------------
Note: The end-users will never see this dataLayer, it is available on the webpage code for tools like Adobe and Google Analytics to use.
Why do you need a Data Layer?
DataLayer makes it easy to store that data that needs to be passed to other tools and systems. Let's seat you need to pass the value of the currency to Adobe or Google Analytics. Without DataLayer, you (the person implementing the GA or Adobe) will need to see which element in the HTML contains the value of the currency, scrape the value from the elements and then pass it analytics tools. Not a big deal right? Now fast forward a few days, you developers/designers release a new version of the page and the value of a currency is now stored in another HTML element. What will happen to your tracking? It will break. Right?
This is where a dataLayer comes in handy. If dataLayer is always present, with the right structure, that you can make any changes you want on the page without breaking the code because implementation will always grab the value from DataLayer.
Who creates the Data Layer?
DataLayer is coded on the page so your website developers will add them to the webpages. Web Analytics implementation team or consultant will provide the specifications if one doesn't already exist.
Need help with DataLayer or Analytics implementation? Don't hesitate to reach out to use for free no-obligation consultation.