I want to get the country of user through Adobe target in cookie value.
I do get geo.country in "delivery" call in Adobe target.
Any other way to achieve this.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
hi @varun790 - there are 2 ways to achieve this:
1. Response tokens:
A. Enable the geo.country response-token
B. Use your applications's code to read it using Custom events (https://experienceleague.adobe.com/docs/target/using/administer/response-tokens.html?lang=en )
C. Update the cookie with the retrieved value
2. Adobe Target activity:
A. Setup an XT activity which runs on all pages (or on specific pages where you want to read country value)
B. In the experience-code, use dynamic parameter to retrieve the value of country.
C. In the same experience-code, add logic to save the country-value in a cookie. Here's sample code:
function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
// Get the Geo-country from Adobe Target
var country = "${profile.geolocation.country}";
// Set the cookie value with the country
setCookie("user_country", country, 90);
hi @varun790 - there are 2 ways to achieve this:
1. Response tokens:
A. Enable the geo.country response-token
B. Use your applications's code to read it using Custom events (https://experienceleague.adobe.com/docs/target/using/administer/response-tokens.html?lang=en )
C. Update the cookie with the retrieved value
2. Adobe Target activity:
A. Setup an XT activity which runs on all pages (or on specific pages where you want to read country value)
B. In the experience-code, use dynamic parameter to retrieve the value of country.
C. In the same experience-code, add logic to save the country-value in a cookie. Here's sample code:
function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
// Get the Geo-country from Adobe Target
var country = "${profile.geolocation.country}";
// Set the cookie value with the country
setCookie("user_country", country, 90);