0

Is it possible to reference my website's dataLayer via Optimizely custom code.

We use Tealium to host our dataLayer -- when writing JS extensions in Tealium I am able to reference UDO variables with simple dot notation:

 if (utag.data.logged_in != true && utag.data.page_type == 'receipt') {

       //do stuff

    }

Optimizely syntax for implementing custom code is as follows:

// ensures the optimizely object is defined globally using
window['optimizely'] = window['optimizely'] || [];

// sends a tracking call to Optimizely for the given event name. 
window['optimizely'].push({
  type: "event",
  eventName: "eventName"
});

Could the same apporach be taken to define the Tealium Data Layer object globally & then use the reference variables in conditional statements?

1 Answers1

1

Yes, as long as the variable is defined in the data layer before your Optimizely snippet runs.

Kristen
  • 11
  • 1