Create Audience on the basis of cookie values | Community
Skip to main content
Level 2
January 25, 2024
Solved

Create Audience on the basis of cookie values

  • January 25, 2024
  • 2 replies
  • 1435 views

I have a requirement where user setting Country code in cookie or local storage.

Then on page load we should get this value and check country code and make condition on basis of that in audience.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by d_venkatesh

Hi @varun790,

 

I meant by adding the mbox parameter using either the launch or target getoffer method. 

 

adobe.target.getOffer({
  "mbox": "target-global-mbox",
  "params": {
     "a": 1,
     "b": 2
  },
  "success": function(offer) {
        adobe.target.applyOffer( {
           "mbox": "target-global-mbox",
           "offer": offer
        } );
  },
  "error": function(status, error) {
      console.log('Error', status, error);
  }
})

 

 

2 replies

Gokul_Agiwal
Community Advisor
Community Advisor
January 25, 2024

Hi @varun790 

Yes, you can able to achieve using Profile Script and that way you can read the cookie and fetch the countryCode value and later used for your defining audience through Visitor Profile section. 

 

Here is the small snippet for read a cookie using Profile script. 

// Read a Cookie var cookies = user.header('cookie'); if (cookies.indexOf('YOUR_COOKIE_VAL') >= 0) {return "true";} else {return "false";} }

Hope this helps. 

varun790Author
Level 2
January 25, 2024

Hi Gokul can you help me getting the cookie values as well here

Adobe Employee
January 25, 2024

Hi @varun790 

 

Since profile scripts run on the server side, direct access to cookie values is not possible. To utilize cookie information at the audience level, first read the cookie value and then pass it as a standard mbox parameter.

 

Hope this helps!

varun790Author
Level 2
January 29, 2024

I am not using mbox since we have upgraded to Adobe target version V2

d_venkateshAdobe EmployeeAccepted solution
Adobe Employee
January 30, 2024

Hi @varun790,

 

I meant by adding the mbox parameter using either the launch or target getoffer method. 

 

adobe.target.getOffer({
  "mbox": "target-global-mbox",
  "params": {
     "a": 1,
     "b": 2
  },
  "success": function(offer) {
        adobe.target.applyOffer( {
           "mbox": "target-global-mbox",
           "offer": offer
        } );
  },
  "error": function(status, error) {
      console.log('Error', status, error);
  }
})