Data Layer
Using a data layer
As defined by Google:
A data layer is a JavaScript object that is used to pass information from your website to your Tag Manager container. You can then use that information to populate variables and activate triggers in your tag configurations.
The Google developer guide is an excellent starting point for understanding how to use a data layer and well worth reading.
For this solution to work you need to ensure you have window.dataLayer
on your website. This is as simple as writing the following code the <head>
of your page:
<script>
window.dataLayer = window.dataLayer || [];
</script>