Context Aware

Context Aware Data Element

General Usage

When accessing data layer values within any context, the use of this data element type is advised as it will take care of the complexity of knowing whether to access the value in the context of the Data Layer Push event or to access the last known value.

Since this Data Element Type is provided by the Data Layer Manager, there is no need to specify anything more than the path of the attribute as provided in the pushed Event Object. In the example below to reference the siteLanguage attribute, we would simply provide page.siteLanguage as the Data Layer Path.

window.appEventData = window.appEventData || [];
window.appEventData.push({
  "event": "Page Loaded",
  "page": {
    "siteLanguage": "en-us",
    "siteCountry": "US",
    "pageType": "product detail",
    "pageName": "pdp - crossfit zoom",
    "pageCategory": "womens > shoes > athletic"
  }
});

Accessing the Root Data Layer Object

If you wish to access the root data layer object, appEventData in all of the examples here), simply leave the Data Layer Path empty.

Directly accessing values within arrays

It is often necessary to access values that exist within arrays of objects. As an example, if we wanted to directly access the productID from within the following example, we would specify product.0.productInfo.productID.

window.appEventData = window.appEventData || [];
window.appEventData.push({
  "event": "Product Viewed",
  "product": [{
    "productInfo": {
      "productID": "10345678934",
      "isOutOfStock" : false
    }
  }]
});

Passing event when using _satellite.getVar

In order for the Context Aware Data Element to have the context of a Data Layer Push Event, the event must be passed into the data element. This is done automatically by Launch when you use the %dataElementName% syntax but it must be passed explicitly when using _satellite.getVar.

Below is an example of this in the javascript of a Code > Custom Code Action

//Core Custom Code Action of a rule triggered by a Data Layer Push Event
var siteLanguageFromEvent = _satellite.getVar("page.siteLanguage", event);
// ^^^ this will evaluate from event.detail.__meta.computedState.page.siteLanguage
//  - or - 
// window.appEventData.computedState.page.siteLanguage is event type is undefined or not a Data Layer Push event


var siteLanguageMostRecent = _satellite.getVar("page.siteLanguage");
// ^^^ this will evaluate from window.appEventData.computedState.page.siteLanguage

Event Context is not available when "Execute Globally" is selected for Core > Custom Code Actions. This is an unfortunate baggage from DTM. There is generally no reason to select "Execute Globally" for this action type.

Optional Transformations

The optional transformations checkboxes were added in v2.1.5 and are pretty self-explanatory; they allow you to transform boolean true to a string value of '1', boolean false to a string value of '0', and undefined to a string value of '0' if desired.

These options are primarily useful when a data element is used to populate an Adobe Analytics Counter or Numeric event.

These all default to being unselected. For the boolean conversions, the evaluation is explicit (i.e. value === true) so only real boolean values will be converted (no loose casting takes place).

Last updated