This extension is currently in beta and has not been fully tested in production.
The Google Data Layer extension allows you to use a Google data layer in your tags implementation. The extension can be used independently or simultaneously with Google solutions and with Google’s open source Data Layer Helper Library.
The Helper Library provides similar event-driven functionality to the Adobe Client Data Dayer (ACDL). The data elements, rules and actions of the Google Data Layer extension provide similar functionality to those in the ACDL extension.
Version 1.0.x of the extension is a beta. This extension has not been fully tested in production.
To install the extension, navigate to the extension catalog in the Experience Platform UI or Data Collection UI and select Google Data Layer.
Once installed, the extension creates or accesses a data layer every time the tag library loads on your website.
When configuring the extension (either while installing the extension or by selecting Configure from the extension catalog) you must define the name of the data layer that the extension consumes. If no data layer with the configured name is present when the library is loaded, the extension creates one instead.
It does not matter whether Google or Adobe code loads first and creates the data layer. Both systems will create the data layer if not present, or use the existing data layer.
By default, the data layer uses the Google default name dataLayer
.
The extension allows you to listen for changes (events) within the data layer. An event can be any of the following:
event
keyword.It is important to understand the use of the event
keyword when data is pushed to a Google data layer, similarly to the Adobe Client Data Layer. The event
keyword changes the behavior of the Google data layer, and therefore the extension’s behavior updates accordingly.
The sections below outline the different event types that the extension can listen for.
If you select this option, the extension listens for any change made to the data layer.
If you select this option, the extension listens for anything being pushed to the data layer, excluding events.
The following example push event would be tracked by the listener:
dataLayer.push({"data":"something"})
The following example push events would not be tracked by the listener:
dataLayer.push({"event":"myevent"})
dataLayer.push({"event":"myevent","data":"something"})
If you select this option, the extension listens for any event pushed to the data layer.
The following example push events would be tracked by the listener:
dataLayer.push({"event":"myevent"})
dataLayer.push({"event":"myevent","data":"something"})
The following example push event would not be tracked by the listener:
dataLayer.push({"data":"something"})
If you want to listen for a specific event, select this option so the event listener tracks any events that match a specific string.
For example, setting myEvent
when using this configuration results in the listener only tracking the following push event:
dataLayer.push({"event":"myEvent"})
You can also use a regex string to match event names. For example, setting myEvent\d
would track events starting with myEvent
followed by a digit:
dataLayer.push({"event":"myEvent1"})
dataLayer.push({"event":"myEvent2"})
The sections below outline the different actions that the extension can perform when included in a rule.
This action pushes JSON content to the data layer itself, making it possible to use data elements directly in JSON payloads. Within the provided JSON editor, you can reference data elements using percent notation (for example, %dataElementName%
).
{
"page": {
"url": "%url%",
"previous_url": "%previous_url%",
"concatenated_values": "static string %dataElement%"
}
}
This action is available from v1.0.5 onward.
This action resets the data layer. If used in a rule which processes a Google data layer change, the data layer is reset to the computed state of the data layer at the time the rule was triggered. If the action is used in a rule which does not process a Google data layer change, the action empties the data layer.
The extension provides a unique data element that accesses the data layer using a key (for example, page.url
in the snippet above).
The data element can provide any of the following:
page.url
)event
keyword was used)The extension always gives priority to event information. If a data layer event
is being processed, values are always read from that event. If an event
is not present, values are read from the directly data layer instead.
Additional information is available in the project README and in the extension’s data element and event dialogs.