Segmenting in Convert Using the dataLayer

Data Layer Definition

A Data Layer is a data structure which ideally holds all data that you want to process and pass from your website to other applications that you have linked to.

A very common example is web analytics tracking. You might have a Data Layer which feeds data into your analytics tool about the visitor. Often, this data isn’t available in the presentational layer, or in the markup at all. This data might be, for example, details about the visitor (login status, user ID, geolocation), metadata about the page (optimal resolution, image copyrights), or even information that’s already in the markup, but that you want to access in a more robust way.

Therefore, you can use this Data Layer to store session visitor data and present later a specific experience to a specific visitor group.

Data Layer Structure

A classic Data Layer would look like the following and would be embedded in your page:

dataLayer = [{
        isLoggedIn: 0,
        userEmail: '',
        industry: 'medical'

Let's assume that the industry field can have different values and we want to target with our experience only users in the medical industry.


First, we need to create the experience that we want to show to this audience group. We need to configure an Advanced Audience for this experience. 

Select Goals:
Then select the "Create an advanced goal" and under Page Tags select JS condition:

mceclip0.pngEnter the following JS code:

(function waitForDataLayer() {
var checkInterval = setInterval(function() {
// Check if dataLayer is defined and has at least one item
if (typeof dataLayer !== 'undefined' && dataLayer.length > 0 && dataLayer[0].hasOwnProperty('industry')) {
// Now check if the industry is 'medical'
if ("medical" == dataLayer[0].industry) {
console.log("Industry is medical.");
// Place any code here that should run after the condition is met
} else {
console.log("Industry is not medical.");
clearInterval(checkInterval); // Clear the interval to stop checking
}, 100); // Check every 100 milliseconds

Then the experience will only run for those visitors whose industry value of the Data Layer equals medical.

Need assistance? Start a conversation with our Support Team.

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features