Expand my Community achievements bar.

SOLVED

Get the user country name in cookie through Adobe Target

Avatar

Level 3

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.

@d_venkatesh @Gokul_Agiwal 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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);

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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);