Hi all
We are currently running our Adobe Target via WebSDK, while the integration is done via Adobe Tags (Adobe Launch).
We would like to leverage response token to pass the Adobe Target experience data to Google Analytics like it's suggested here:
https://experienceleague.adobe.com/en/docs/target/using/administer/response-tokens
Our questions:
Thanks!!!!
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Hey @RaymondCh4
Yes, you can integrate the AT response tokens and pass the data to Google Analytics via Launch however simply copy the code from documentation might not help so below is the complete snippet. See if this helps for you.
Also you asked above - any alternative way to integrate code other than Launch, so the answer is yes however there are pros and cons and I'm sure for those way you've to dependent on with your other departments. Still let's discuss other alternatives.
1) Direct script injection on the website - see if you have an access to codebase and I'm sure you need to be discuss this with your dev team.
2) Server side solution.
Recommended approach -
Use Adobe Launch ( Data Collection) as this gives better control and both your web sdk and Target configuration in Launch only.
So I would suggest to align with your department who manage the changes for Adobe Launch and let them know about below so they will guide you.
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script type="text/javascript">
// Initialize Google Analytics
// Send Adobe WebSDK event
alloy("sendEvent", {
type: "web",
renderDecisions: true
})
.then(({ renderedPropositions, nonRenderedPropositions }) => {
// Concatenate all propositions
const propositions = [...renderedPropositions, ...nonRenderedPropositions];
// Extract response tokens from propositions
const extractResponseTokens = (propositions) => {
return propositions.flatMap(proposition =>
(proposition.items || []).map(item => item.meta || {})
);
};
const tokens = extractResponseTokens(propositions);
// Ensure unique tokens
const distinct = (tokens) => {
const seen = new Set();
return tokens.filter(token => {
const identifier = token["activity.name"] + token["experience.name"];
if (seen.has(identifier)) {
return false;
}
seen.add(identifier);
return true;
});
};
const uniqueTokens = distinct(tokens);
// Collect activity names and experience names
const activityNames = [];
const experienceNames = [];
uniqueTokens.forEach(token => {
if (token["activity.name"]) activityNames.push(token["activity.name"]);
if (token["experience.name"]) experienceNames.push(token["experience.name"]);
});
// Send the event to Google Analytics
gtag('event', 'adobe_target_experience', {
'event_category': 'Adobe Target',
'event_action': experienceNames.join(', '),
'event_label': activityNames.join(', ')
});
})
.catch(error => {
console.error("Error sending event to Adobe Target:", error);
});
</script>
Hope this helps. Feel free to post question if not solve.
Thanks
Yes, you can add the script to Adobe Launch by creating an additional action after the WebSDK call. Ensure the response token data is properly captured and passed to Google Analytics as outlined in the documentation.
@TamseelBl thanks for your feedback.
May I ask part from adding the script to Launch, is there other way to integrate without touching Launch? As we have different departments managing different parts of the integration, want to make sure we know the different possibilities. And which will be the recommneded practice.
Thanks!
Hey @RaymondCh4
Yes, you can integrate the AT response tokens and pass the data to Google Analytics via Launch however simply copy the code from documentation might not help so below is the complete snippet. See if this helps for you.
Also you asked above - any alternative way to integrate code other than Launch, so the answer is yes however there are pros and cons and I'm sure for those way you've to dependent on with your other departments. Still let's discuss other alternatives.
1) Direct script injection on the website - see if you have an access to codebase and I'm sure you need to be discuss this with your dev team.
2) Server side solution.
Recommended approach -
Use Adobe Launch ( Data Collection) as this gives better control and both your web sdk and Target configuration in Launch only.
So I would suggest to align with your department who manage the changes for Adobe Launch and let them know about below so they will guide you.
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script type="text/javascript">
// Initialize Google Analytics
// Send Adobe WebSDK event
alloy("sendEvent", {
type: "web",
renderDecisions: true
})
.then(({ renderedPropositions, nonRenderedPropositions }) => {
// Concatenate all propositions
const propositions = [...renderedPropositions, ...nonRenderedPropositions];
// Extract response tokens from propositions
const extractResponseTokens = (propositions) => {
return propositions.flatMap(proposition =>
(proposition.items || []).map(item => item.meta || {})
);
};
const tokens = extractResponseTokens(propositions);
// Ensure unique tokens
const distinct = (tokens) => {
const seen = new Set();
return tokens.filter(token => {
const identifier = token["activity.name"] + token["experience.name"];
if (seen.has(identifier)) {
return false;
}
seen.add(identifier);
return true;
});
};
const uniqueTokens = distinct(tokens);
// Collect activity names and experience names
const activityNames = [];
const experienceNames = [];
uniqueTokens.forEach(token => {
if (token["activity.name"]) activityNames.push(token["activity.name"]);
if (token["experience.name"]) experienceNames.push(token["experience.name"]);
});
// Send the event to Google Analytics
gtag('event', 'adobe_target_experience', {
'event_category': 'Adobe Target',
'event_action': experienceNames.join(', '),
'event_label': activityNames.join(', ')
});
})
.catch(error => {
console.error("Error sending event to Adobe Target:", error);
});
</script>
Hope this helps. Feel free to post question if not solve.
Thanks
Thank you for the detailed answer, we will try it out and will post it here whether it works or not. Thanks again!!!
@RaymondCh4 Sure, let us know how it goes. Feel free to post your observation.
Just ensure the response token is captured correctly and passed to Google Analytics via the appropriate event. Copying the code snippet should work, but make sure to test it in a staging environment before deploying it live
Views
Likes
Replies