Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Target Mbox call Issue

Avatar

Level 2

Hi Team ,

 

We are geeting the response Segment ID from the API call. This segemnt ID we are saving local storage. And my custom code passing the target using DATA provider .

 

Sample :

callback(null, {td_segment:localStorage.getItem("td_segment")});

And I'm creating target audience passing parment and the segemnt values 

 

Mr_Moorthi_0-1659681024222.png

 

But in delivery call not seen different experience. Please suggest what is best way to achive this.

Thing is have to show differnt segment users for different content.

 

Thanks In Advance !!!

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 6
var segmentProvider = {
  name: "segmentProvider",
  version: "1.0.0",
  timeout: 1000,
  callback: null,
  provider: function (callback, params) { 
    
  ...

 

It is important that your API request is also ready before the callback is called.
With the XMLHttpRequest this is for example onreadystatechange if (this.readyState == 4 && this.status == 200) is given.

 

After that you can write e.g. a cookie or something into the localStorage.

 

As I understand you, you want to read something from the localStorage.

 

var data = window.localStorage.getItem('td_segment') || '{}';
// here if necessary still regex etc.

 

Then call the callback
callback(error, data);

 

I would then output the segment as a ResponseToken. If this fits - you can then create your audience.
 
hope this helps you further
best regards

View solution in original post

1 Reply

Avatar

Correct answer by
Level 6
var segmentProvider = {
  name: "segmentProvider",
  version: "1.0.0",
  timeout: 1000,
  callback: null,
  provider: function (callback, params) { 
    
  ...

 

It is important that your API request is also ready before the callback is called.
With the XMLHttpRequest this is for example onreadystatechange if (this.readyState == 4 && this.status == 200) is given.

 

After that you can write e.g. a cookie or something into the localStorage.

 

As I understand you, you want to read something from the localStorage.

 

var data = window.localStorage.getItem('td_segment') || '{}';
// here if necessary still regex etc.

 

Then call the callback
callback(error, data);

 

I would then output the segment as a ResponseToken. If this fits - you can then create your audience.
 
hope this helps you further
best regards