Hi @abhinavpuri ,
The goal here is to make sure that no data is collected when the user is denying consent with OneTrust.
Here is the sequence of events on a landing page, assuming that the visitor lands on the website for the first time.
1) visitor lands on the page
2) during page load AT is modifying the page to set up the experience for the A/B test
3) data is sent to Adobe to notify the page view to Adobe Target
4) OneTrust banner appears on the page
Now, if the visitor is denying tracking, we have a problem as we already sent data to Adobe Target. Under the strict interpretation of GDPR this is not acceptable. So what I need to do, is to delay sending data to Adobe Target until consent is given. At the same time I need to load the experience of the A/B test before everything else.
In my setup, at.js is harcoded on the page.
At the end of at.js I have appended the following code, to send a datalayer push to know exactly when Adobe Target fires:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(
{
'event': 'adobeTargetFired'
});
document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function (e) {
var tokens=e.detail.responseTokens;
if (isEmpty(tokens)) {
return;
}
var uniqueTokens = distinct(tokens);
uniqueTokens.forEach(function(token) {
window.dataLayer.push({
'event': 'adobeTargetExperimentTokens',
'targetActivityName': token["activity.name"],
'targetActivityId' : token["activity.id"],
'targetExperienceName': token["experience.name"],
'targetExperienceId': token["experience.id"],
'targetOfferId': token["offer.id"],
'targetOfferName': token["offer.name"],
'targetMboxName': e.detail.mbox});
});
});
function isEmpty(val){
return (val === undefined || val == null || val.length <= 0) ? true : false;
}
function key(obj) {
return Object.keys(obj)
.map(function(k) { return k + "" + obj[k]; })
.join("");
}
function distinct(arr) {
var result = arr.reduce(function(acc, e) {
acc[key(e)] = e;
return acc;
}, {});
return Object.keys(result)
.map(function(k) { return result[k]; });
}
Do you have any suggestions?