order_value > 100 — or on a specific event — for example, when the video was seen.
You can think of the data layer as of a universal data structure that contains essential data about events and information displayed on the page, in a format that can be utilized by third-party tools and scripts.
In this article, we’ll explain how to create a data layer.
A data layer object is an array containing key/value pairs. Use the following snippet to create a new data layer:
<script>window.dataLayer = window.dataLayer || ;</script>
Note the position of the snippet in relation to the containers code. We strongly recommend to paste the data layer snippet before the containers code, like this:
<head> ... <script>window.dataLayer = window.dataLayer || ;</script> <!-- Piwik PRO Tag Manager synchronous container code --> </head> <body> <!-- Piwik PRO Tag Manager asynchronous container code --> ... </body>
When a data layer is created after the container, some tags may behave inappropriately or not fire at all. The data layer content is not persisted between page views. This means you have to redeclare the variables on each separate page. It is also common to use different values for different pages.
A good example of a data layer would be a page category variable. If you assign it on every page, you could show a pop-up only to people interested in a specific type of content like a product, contact or homepage.