Ascend has lifecycle events which enable you to track and store Ascend event data. Some common use cases are the following.

  1. Making Ascend candidates (treatments) persist cross-device.
  2. Sending event data to a 3rd party or in-house analytics tools for custom reports.

Ascend Life Cycle Events Implementation Documentation

The following implementation details include information on getting Ascend experiment data for storage to enable support for cross-device user tracking and consistent treatments served to users.

Getting Ascend experiment data

To get the necessary Ascend information for storage you'll need to implement Ascend listeners immediately after the Ascend JavaScript snippet.

Namespace: ascend

Method Detail: ascend.on(event, callback)

The following sample code illustrates how to set an event listener immediately after the snippet.

 
ascend.on('selected', function(data)
{
//Store the following variables
//data.candidate_id
//data.user_id
//data.experiment_id
});

Setting Ascend experiment data

To set the experiment data so the user sees the same treatment cross device you'll need to fetch the stored Ascend data then populate the window.AscendCandidate object.

The following is sample code to demonstrate how to set the information.

//Fetch the Ascend data using your own mechanism 
window.AscendCandidate = {
  "candidate_id" : candidateID,
  "user_id": userID,
  "experiment_id" : experimentID
}

Passing the Adobe ID to Ascend for storage

In order to pass the Adobe ID to Ascend, you'll need to populate the window.AscendUser object. Please see the following sample code for details

 
window.AscendUser = {"adobe_uid" : 123 }
 

Example code for lifecycle events provided below


var ascendEventsQueue = [];
var ascendEventsNames = [
  'filtered',
  'selected',
  'rendered',
  'notrendered',
  'triggered',
  'errored'
];
var ascendEventsHandler = function(eventName, eventData) {
  ascendEventsQueue.push({
  name: eventName,
  data: eventData
});
};
var subscribeToAscendEvents = function() {
  if (window.ascend) {
    ascendEventsNames.forEach(function(eventName) {
      ascend.on(eventName, function(eventData) {
        ascendEventsHandler(eventName, eventData);
      });
    });
  }
}
Did this answer your question?