Back to All

What is a data layer?

The term "data layer" sounds technical but can be thought of as simply a bucket for holding special values that your tags may need - dynamic data like the current state of a shopping cart, for example.

In order to function on a website along with your tags, the data layer must be implemented in JavaScript.

Speaking more technically, the data layer is a JavaScript variable that often represents an array - JavaScript's way of representing a list of arbitrary values:

<script>
  var exampleDataLayer = []; // an empty JavaScript array
</script>

Google Tag Manager's Developer Guide walks through setting up a data layer specifically for GTM.

Mozilla's web docs include an introduction to JavaScript arrays.