As soon as you start working with a tag management systemTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page., you’ll inevitably confront the term Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system..
It’s a difficult concept to pin down. But as a technical marketer, it’s one of the key instruments to understand if you want to manage the tagsNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. and marketing scripts running on a web page more efficiently.
There are many definitions of the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system., so it’s perhaps easier to focus on what it’s not and what problems it solves.
Think of a web page as comprising layers.
The presentation layer is what the user sees and interacts with. It typically includes mainly HTMLHyperText Markup Language (HTML) is used to describe how web documents should be rendered by the web browser. When you navigate to a web page, the web server hosting that page serves your browser an HTML source file that is then rendered into the visible and interactive web page. (the content) and CSSCascading Stylesheets, or CSS, is a web technology that describes how the web page should look like and, up to a certain point, respond to interactions. If the HTML document defines the content, then CSS describes how that content should be structured, aligned, and painted in the browser. (the styles).
The business logic (or experiential) layer is what governs the user experience of the web page.
Example
For example, button clicks, form input fields, content accordion toggles, videos, etc. would be controlled by the business logic layerThe business logic layer is what defines how interactive elements such as forms, buttons, and links work. It also includes dynamic actions such as content that is loaded only once the user scrolls to the bottom of the visible page.. The language of this layer is predominantly JavaScriptJavaScript is the main language of the dynamic web. The web browser renders the HTML source file into a dynamic document that can be interacted with using JavaScript., although there are many things in HTMLHyperText Markup Language (HTML) is used to describe how web documents should be rendered by the web browser. When you navigate to a web page, the web server hosting that page serves your browser an HTML source file that is then rendered into the visible and interactive web page. and CSSCascading Stylesheets, or CSS, is a web technology that describes how the web page should look like and, up to a certain point, respond to interactions. If the HTML document defines the content, then CSS describes how that content should be structured, aligned, and painted in the browser. that can control the page experience, too.
And then you have the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system.. It’s not as clearly defined as the previous two layers, as its main utility is in the niche realm of marketing technologies. The reason it’s separated from the other two layers is that it’s not supposed to be involved with the presentation or the business logic of the web page.
The purpose of the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. is to be a single, well-known structure on the web page that can be utilized for passing information to and from marketing technology tools, especially tagNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. management systems (TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page.).
Example
Instead of the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. having to scrapeSome tracker libraries can be configured to scrape information from the page. This means that they use JavaScript to access information on the page rather than going through, for example, a Data Layer. Scraping can be hazardous if done autonomically, because analytics systems can end up inadvertently scraping credit card numbers of other sensitive data. e-commerceE-commerce represents the industry of online sales. E-commerce covers online transactions that happen on the web, among other things. data from the presentation layerThe presentation layer of a web page is built with HTML and CSS, although JavaScript can also be used to dynamically change elements of this layer. It's the visible content of the web page, including the structure of the visible content, such as the grid layout or the responsive design of the page., such as when the user is shown a “Thank You” page with a receipt, the same information could be duplicated in the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. by the site developers.
The TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. can then access this information without having to worry about changes in the presentation or business logic layers messing up the data collection.
The Data Layer and the TMS
Many TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. are built with a certain type of Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. in mind.
Two common approaches are a set Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. objectObject is a JavaScript construct that comprises key-value pairs. The Data Layer (a type of object itself) typically consumes objects of data. and an event-drivenAn event-driven Data Layer is one that both feeds data to a TMS and triggers the tags within the TMS. A TMS would attach "listeners" to an event-driven Data Layer, so that it can react to new data that is added to the Data Layer. Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system., with the latter more popular than the former.
The main purpose of the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. is to allow the site and the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. to pass information from one to the other.
For example, here is a fairly typical page initialization Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. that is added to the page HTMLHyperText Markup Language (HTML) is used to describe how web documents should be rendered by the web browser. When you navigate to a web page, the web server hosting that page serves your browser an HTML source file that is then rendered into the visible and interactive web page. template before the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. is loaded:
// Initialize the Data Layer
window.dataLayer = window.dataLayer || [];
// Add the page initialization metadata to the Data Layer
window.dataLayer.push({
event: 'pageInit',
page: {
url: 'https://www.teamsimmer.com/',
title: 'Online courses in technical marketing',
id: 'lp1_a'
},
user: {
loginStatus: true,
id: '91e41dee-2b33-4705-bdd5-b0abc5509a09'
},
environment: {
type: 'live',
dlGenerated: 1683955875477
}
});
The key-value pairsKey-value pair is a generic term used to describe the contents of an object. An object is a data structure that can have zero or more key-value pairs. Each object can have just one of any given key, and the key always needs to point to some value. (for example event: 'pageInit'
) that are added to the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. are then consumed by the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page., and they become available as some type of references within the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. itself, for example as variablesVariables are (usually small) pieces of code run in a TMS to fetch dynamic values for tags when they fire. A defining feature of variables is that they are re-evaluated whenever a tag fires. For example, if a variable fetches the exact time when a tag fired, it's important that it doesn't use the same, fixed value for all tags on the page. that tagsNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. can utilize.
The code example above is of an event-drivenAn event-driven Data Layer is one that both feeds data to a TMS and triggers the tags within the TMS. A TMS would attach "listeners" to an event-driven Data Layer, so that it can react to new data that is added to the Data Layer. Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system., such as that used by Google TagNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. Manager.
The value of the event
key ('pageInit'
in this case) can be used by the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. as a rule triggerA tag management system uses triggers (also known as rules) as activation instructions for tags. When trigger conditions are satisfied, any tags that reference that trigger can fire.. The TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. “listens” to these Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. interactions, and tagsNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. can be configured to fire when the 'pageInit'
event is added to the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system..
When the tagNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. then fires, it can pull in the page.url
and page.title
keys, along with all the data nested in the user
objectObject is a JavaScript construct that comprises key-value pairs. The Data Layer (a type of object itself) typically consumes objects of data.. The environment.type
value could be used to determine whether to collect the data to a “live” analytics trackerSoftware that typically runs in the user's web browser or device, designed to collect data from the user to a server. or to a “staging” or “test” trackerSoftware that typically runs in the user's web browser or device, designed to collect data from the user to a server..
In summary, this single JavaScriptJavaScript is the main language of the dynamic web. The web browser renders the HTML source file into a dynamic document that can be interacted with using JavaScript. dataLayer.push()
call can not only fire tagsNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. but also populate them with data from the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system.. The event-drivenAn event-driven Data Layer is one that both feeds data to a TMS and triggers the tags within the TMS. A TMS would attach "listeners" to an event-driven Data Layer, so that it can react to new data that is added to the Data Layer. Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. thus combines both the message transfer system and the triggering system into a single, operational logic.
The other type of Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system., a set Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. objectObject is a JavaScript construct that comprises key-value pairs. The Data Layer (a type of object itself) typically consumes objects of data., separates the two systems. With this approach, the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. would be populated just as above, but the triggering logic would be operated with some other method unrelated to the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. itself.
Ready for a quick break?
Take a short break – that’s what all your layers require to digest the information in this Topic.
Prescriptive vs. descriptive approaches
Since the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. is all about collecting and forwarding data between two systems, adopting a naming conventionA set of instructions for how to name keys within the Data Layer. For example, a naming convention could dictate that all keys need to be in snake_case rather than in camelCase. is vital.
Having a predictable and well-documented approach to naming things in the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. will prevent many issues down the line.
There is no agreed standard for how to name things in the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system., so the type of schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. to adopt mostly depends on the company doing the deployment. Their expertise and understanding of the various marketing technology integrations added to the site will determine the shape, size, and functionality of the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system..
However, sometimes marketing technology vendors place specific requirements on not only the values in the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. but also the general structure as well.
For example, one vendor might require a shopping cart to be represented like this:
items: [{
item_id: 'shirt_123',
item_name: 'My shirt',
price: 10.00,
quantity: 1
}]
Another vendor might require this:
contents: [{
id: 'shirt_123',
value: 10.00
}]
These represent the vendors offering a prescriptiveA prescriptive approach to Data Layer design is one where a vendor dictates the naming conventions and the structures of the Data Layer. Usually the purpose is to allow the vendor to directly integrate with the Data Layer rather than having to go through a TMS or to have the data transformed with variables. schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. for ordering things in the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system.. Their integrations can make use of the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. directly if the contents are in this format.
The other approach is a descriptiveA descriptive schema is built so that the data is structured to suit the needs and requirements of the company managing the website rather than the marketing vendors the company works with. one, where instead of complying with the vendor recommendations above, the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. takes a more generic approach, such as this:
cart_items: [{
sku: 'shirt_123',
name: 'My shirt',
price: 10.00,
quantity: 1
}]
In this case, the final schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. is somewhat similar to the vendors’ requirements but still different enough to not directly work with either. In this case, the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. needs to include transformations (using variablesVariables are (usually small) pieces of code run in a TMS to fetch dynamic values for tags when they fire. A defining feature of variables is that they are re-evaluated whenever a tag fires. For example, if a variable fetches the exact time when a tag fired, it's important that it doesn't use the same, fixed value for all tags on the page.) that take this item in the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. and map it to the format required by each vendor.
Which approach you go with really depends on how important these integrations are to you. If almost all of your tagsNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. have to do with marketing vendors that all have the same prescriptiveA prescriptive approach to Data Layer design is one where a vendor dictates the naming conventions and the structures of the Data Layer. Usually the purpose is to allow the vendor to directly integrate with the Data Layer rather than having to go through a TMS or to have the data transformed with variables. schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. recommendation, the modeling the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. after this might be a good idea.
PrescriptiveA prescriptive approach to Data Layer design is one where a vendor dictates the naming conventions and the structures of the Data Layer. Usually the purpose is to allow the vendor to directly integrate with the Data Layer rather than having to go through a TMS or to have the data transformed with variables. approach | DescriptiveA descriptive schema is built so that the data is structured to suit the needs and requirements of the company managing the website rather than the marketing vendors the company works with. approach |
---|---|
Easier to deploy. | More difficult to deploy. |
More difficult to integrate other vendors. | Easier to integrate other vendors. |
Requires transformations for vendors who do not support this schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer.. | Requires transformations for most if not all vendors. |
Transformations might be more complicated because the starting point is skewed towards the schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. vendor. | Transformations are likely to be simpler because the starting point is a generic data structure. |
However, the generic descriptiveA descriptive schema is built so that the data is structured to suit the needs and requirements of the company managing the website rather than the marketing vendors the company works with. approach is often better. All TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. support transformations, and having a generic Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. that is not beholden to any specific vendor schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. makes it easier to add additional tools and services as integrations later.
Following a single vendor’s schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. too strictly might make it difficult to integrate other vendors whose platforms require the data to be in a vastly different format.
Key takeaway #1: Separate layer for semantic data
The Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. should be kept separate from the presentation and the business logic layers of the site. Its purpose is to store information that is not directly linked to the HTMLHyperText Markup Language (HTML) is used to describe how web documents should be rendered by the web browser. When you navigate to a web page, the web server hosting that page serves your browser an HTML source file that is then rendered into the visible and interactive web page. elements or other functionality of the page. The contents of the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. can certainly mirror the content on the page. For example, on a receipt page the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. can repeat the information the user sees about their purchase. But the two layers are kept separate – changes in one should not affect the other.
Key takeaway #2: Event-driven Data Layer is the modern approach
The event-drivenAn event-driven Data Layer is one that both feeds data to a TMS and triggers the tags within the TMS. A TMS would attach "listeners" to an event-driven Data Layer, so that it can react to new data that is added to the Data Layer. Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system., popularized by Google TagNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. Manager, is an approach where the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. both includes the semantic information relevant to the page and the actions the user takes and instructs the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. when to utilize this information to fire the tagsNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors.. As new information is made available, it is added to the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. event queue, where the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. can then pull the data and act on it as it becomes available.
Key takeaway #3: Prescriptive vs. descriptive Data Layer
Some vendors integrate directly with the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. to minimize the taggingNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. overhead of setting up data collection in the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page.. In these cases, the vendors often prescribe a specific schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. for the content in the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system.. While this makes it easier to work with the vendor, it does place additional overhead on getting the developers to follow the schemaAn analytics system uses schemas to parse, validate, and store events ingested by the collector. The schema dictates what a valid event looks like, what data types are accepted by the system, and what values are required in all incoming events. Schema can also be used to describe the structure of other things, such as the Data Layer. exactly rather than work with something more generic. A descriptiveA descriptive schema is built so that the data is structured to suit the needs and requirements of the company managing the website rather than the marketing vendors the company works with. approach allows the taggingNormally, tag references an HTML element (or node). In a marketing context, tags are used to denote HTML elements and JavaScript snippets specifically designed for collecting data to marketing vendors. team to build the Data LayerA globally available JavaScript structure on the web page designed to pass information between the web page and the tag management system. in a generic way, and then use the TMSTMS are software designed to create, manage, and deploy tags on web pages. They offer a user interface for managing the marketing tags on any given page. to map this data into the format each vendor requires.