Last active
April 27, 2022 18:22
-
-
Save lesutton/39e496fbfed8f43b77b2a0c81f418bfd to your computer and use it in GitHub Desktop.
Adobe Target Data Layer Event Push
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
console.log("Adobe Target: Setting event listener: adobe.target.event.REQUEST_SUCCEEDED"); | |
document.addEventListener(adobe.target.event.REQUEST_SUCCEEDED, function(e) { | |
console.log("Adobe Target: Event detected"); | |
var tokens = e.detail.responseTokens; | |
if (isEmpty(tokens)) { | |
return; | |
} | |
var uniqueTokens = distinct(tokens); | |
uniqueTokens.forEach(function(token) { | |
activityName = token["activity.name"]; | |
window.dataLayer.push({ | |
'event': [{ | |
'activity.decisioningMethod':token["activity.decisioningMethod"], | |
'activity.id':token["activity.id"], | |
'activity.name':token["activity.name"], | |
'experience.id':token["experience.id"], | |
'experience.name':token["experience.name"], | |
'experience.trafficAllocationId':token["experience.trafficAllocationId"], | |
'experience.trafficAllocationType':token["experience.trafficAllocationType"], | |
'geo.city':token["geo.city"], | |
'geo.connectionSpeed':token["geo.connectionSpeed"], | |
'geo.country':token["geo.country"], | |
'geo.dma':token["geo.dma"], | |
'geo.domainName':token["geo.domainName"], | |
'geo.ispName':token["geo.ispName"], | |
'geo.mobileCarrier':token["geo.mobileCarrier"], | |
'geo.state':token["geo.state"], | |
'geo.zip':token["geo.zip"], | |
'offer.id':token["offer.id"], | |
'offer.name':token["offer.name"], | |
'option.id':token["option.id"], | |
'option.name':token["option.name"], | |
'profile.activeActivities':token["profile.activeActivities"], | |
'profile.categoryAffinities':token["profile.categoryAffinities"], | |
'profile.categoryAffinity':token["profile.categoryAffinity"], | |
'profile.daysSinceLastVisit':token["profile.daysSinceLastVisit"], | |
'profile.isFirstSession':token["profile.isFirstSession"], | |
'profile.isNewSession':token["profile.isNewSession"], | |
'profile.marketingCloudVisitorId':token["profile.marketingCloudVisitorId"], | |
'profile.thirdPartyId':token["profile.thirdPartyId"], | |
'profile.tntId':token["profile.tntId"] | |
}] | |
}); | |
}); | |
console.log("Adobe Target: Data layer prepared"); | |
dataLayer.push({'event':'FireGoogleAnalytics'}); | |
} | |
); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment