What is a Data Layer and how can it help your online business?

Article written by Claudiu Murariu

Can websites really be optimized with the data available now in Google Analytics? The answer is yes, but it takes a lot of effort. Fear not: data layers, tag managers and tones of free tutorials are here to help and make it much easier for you.

Advanced implementations might look a little scary, especially if you consider yourself a non-technical person, but put some patience in it. You can always ask a colleague who is comfortable with tracking codes to explain the technical parts.

Web analytics can really be a gold mine, inches away from your fingers. The following article tries to prove just that.

Your current web analytics implementation

imagine 1

Google Analytics does a great job in tracking URLs, clicks and if you went a little bit deeper with your implementation you are also tracking sales. That’s about it.

Tones of data comes along with those URLs and click events but you know more than anyone else when was the last time that click and event data helped you increase your business.

Tracking clicks and paths does not mean tracking behavior. They are hints of behavior but they are not behavior. To analyze behavior you need to put click data into context.

Let’s take a real world scenario: optimize the site search.

Let’s say you want to analyze what people are searching on your website and you want to do the correlation between searched keywords and sales. You identify the keywords that convert the worst and you want to take action to fix this. So, your current implementation tells you that have a problem but doesn’t give you any hint on what the problem is.

Intuition vs Data

You will go to your website and search for each keyword that has a sub-optimal conversion rate and look for hints of what might be wrong. After 10 or 20 keywords of the hundreds you identify, you realize things are not as easy as you thought and you find many possible reasons why conversion rate is down for your set of keywords but can’t decide on one thing to improve. It’s down to your intuition on how to proceed.

The truth is that you need statistical data that will tell you what are context elements that have a negative influence on your conversion rate.

Wouldn’t it be great if Google Analytics could offer that data as well? For that, we need to log contextual data for each new search a user does on your website. Data like:

  • number of results for each search
  • price ranges of the products in the search
  • categories and subcategories of the products from the search results
  • applied filters
  • CTR for product placements

The list could go on to include pretty much everything that is important for your business. Can Google Analytics log all these? Yes. How? With the help of data layers.

How can a data layer help?

Technically speaking, a data layer is a JavaScript object that contains all the contextual data of a page and the user behavior on that page.

Think of it as a sentence that describes the page and the user behavior on it, hidden from his eyes, available to your Google Analytics implementation.

For the above search analysis example, here is how a data layer would look like:

Here are just a few other things that you could find really helpful when analyzing data:

  • Product page
    • product price
    • product category
    • number of pictures of the product
    • available product options
    • length and style of product description
    • delivery details
    • number of reviews
  • Search page
    • applied filters
    • applied sorting
    • number of results for search
    • searched keyword
  • Shopping cart
    • number of added products
    • price range of added products
    • product categories
    • deleted products

Focus on Business Questions

With the above data properly logged inside Google Analytics, you will have enough data to easily answer the following business questions:

  • Are people finding the products they are looking on our website?
  • Is our offer meeting the requests of our visitors: is there correlation between pricing and categories of viewed products compared to purchased products?
  • What is the impact of free delivery on sales?
  • How much would sales increase if more products would have reviews from past customers?
  • People who refine product selection are more likely to end up finding their desired product or more likely to abandon the website without buying?

Now that’s how actionable analytics looks like.

Well, even if you define a data layer for your online store, such contextual data won’t get to your Google Analytics account by just placing the default tracking code on your website.

It is not that difficult either with the help of Google Tag Manager, a product designed to get context data such as data layers into Google Analytics or other similar products.

Using data layers

This gets a little technical but I’ll do my best to make it easy to digest and understand. While you don’t need to do the actual coding, it helps knowing what is involved.

To be able to send contextual page data to Google Analytics we will need the data layer to be implemented on the website in a specific format, documented by Google.

Create a Google Tag Manager account. It will provide you a JavaScript code that will replace the existing Google Analytics code on your website. Yep, there will be no more tracking codes directly on your website (or any other web analytics codes for that matter as they can all be moved to Google Tag Manager).

Assuming you have implemented a similar data layer for your search results that I offered as an example in the previous paragraphs, here is how the implementation logic would look for it inside Google Tag Manager.


Tag 1. Initialize Google Analytics – run on any page



Tag 2. Track Search Page context data – run only on search pages, only after the first tag was initiated

Similar tags can be generated for product pages, category and brand pages, shopping carts and any other page on the website.

Generating reports based on contextual data

Just like until now, reports can be accessed directly inside your Google Analytics account. The Google Analytics reporting interface is really powerful, but not without limitations. If you want to get the most out of it, I suggest to turn to the Google Analytics API.

Don’t worry, no need to get your hands dirty and write codes for this one. There is a really easy to use tool to get data directly into Google Docs via the Google Analytics API. You can manipulate the data in any way you think possible getting real answers to business questions.

Going go back to the challenge that started us on this journey, you need to identify the correlation between searched keywords and sales. Let’s identify all the keywords that trigger a sub-optimal conversion rate and look at the contextual data that comes along as well.

Here is how the requests to Google Analytics will look like:

You will need to do some tweaking and manipulation of data but answers are much closer to you now.

Need help with Google Analytics API requests

The free Query Explorer tool provided by Google helps me a lot in generating new queries to Google Analytics and get the data I need.

Here is how to setup Google Docs to get that data from Google Analytics via the API:

Once data gets in, feel free to generate charts and apply calculations to the data you get and find out what are the main segments of under-performing keywords and what do they have in common.

Now make a one page analysis, send it to your managers and get the green light to optimize the issues you just found. Ask for a raise while you are at it.

Going the extra mile

Data layers are amazing tools in helping you analyze your website performance. With PadiAct we realized we can use data layers for targeting purposes also.

If you have a data layer implemented on your website, you can target people based on the context of the pages they are on.

Want to target people that are viewing mostly products with discounts? Tell them you can offer monthly discounts in their inbox directly.

What are your feelings for advanced web analytics implementations? Do they make you feel reluctant due to their complexity or do you look forward to have them tested on your website?


What is a Data Layer and how can it help your online business? by

1.100.000+ email leads collected with

PadiAct helps you get more email leads. More and better.