Target Mbox call Issue | Community
Skip to main content
Level 2
August 5, 2022
Solved

Target Mbox call Issue

  • August 5, 2022
  • 1 reply
  • 651 views

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 

 

 

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 !!!

 

 

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 Perrin_Ennen
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

1 reply

Perrin_Ennen
Community Advisor
Perrin_EnnenCommunity AdvisorAccepted solution
Community Advisor
August 9, 2022
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