Ascend Life Cycle Events Implementation Documentation

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.

<script src="//media.ascend.ai/c/XXXXXXXXX-1/ascend.js"></script> 
<script>

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

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}

<script src="//media.ascend.ai/c/263109793-1/ascend.js"></script>

Passing the Adobe ID to Sentient for storage

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

<script> 
window.AscendUser = {"adobe_uid" : 123 } 
</script>

<script src="//media.ascend.ai/c/263109793-1/ascend.js"></script> 

Example code for lifecycle events provided below

<script>
var sentientEventsQueue = [];
var sentientEventsNames = [
'filtered',
'selected',
'rendered',
'notrendered',
'triggered',
'errored'
];

var sentientEventsHandler = function(eventName, eventData) {
sentientEventsQueue.push({
name: eventName,
data: eventData
});
};

var subscribeToSentientEvents = function() {
if (window.ascend) {
sentientEventsNames.forEach(function(eventName) {
ascend.on(eventName, function(eventData) {
sentientEventsHandler(eventName, eventData);
});
});
}
}
</script>

<script src="//media.ascend.ai/c/XXXXXXXX-1/ascend.js" onload="subscribeToSentientEvents()"></script>
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk