Storing and Retrieving data dynamically in Target

Mark_47

04-03-2020

I currently have an activity that stored product information into the localStorage ~ This is all done through Javascript (custom code option). 
I then read from the local storage and display a popup with the product information on other pages.

Is there a way to move away from localStorage and instead store the product information in Adobe Target instead?
If so, how would I go about this?

I've had a look at profile scripts, thinking that I could send a json object to the profile script to either save a new value or just return what it has stored.
I've looked at mboxes and some adobe.target functions. None of which do what I want or at least I don't think it does. 
I've looked at the targetPageParams() function, but I'm not sure how this works. 

Adobe Target cookies dynamic data localStorage mbox retreive store

Accepted Solutions (1)

Accepted Solutions (1)

LordOfTheRings

04-03-2020

Hi @Mark_47 , you are using localStorage it seems you want to use the product info for the session for future use.

 

You can achieve the similar behaviour through mbox profile parameters. Fire a monitoring campaign and its parameters as profile parameters. Please refer below :

 

adobe.target.getOffer({
"mbox": "localMbox",
"params": {
"profile.productId": "12345",
"profile.productCategory":"Clothing"

},
"success": function(offer) {
adobe.target.applyOffer( {
"mbox": "localMbox",
"offer": offer
} );
},
"error": function(status, error) {
console.log('Error', status, error);
}
});

The profile.productId value will remain present for whole session . Hope that helps you

Hi @LordOfTheRings ,

Thanks for the response.
Once I've executed the above command, how would I get the profile productId.

My scenario is 1 activity, but 2 pages. The first being the data collecter and the 2nd being the pop-up.
How would I get that value into a javascript variable to use in the 2nd page (the pop-up code).

Thanks :3

If I understand the requirement correctly , on 1st page you want to collect the data and on the 2nd page you want to use the colllected data to show the popup. is that right ?
If yes, then on the first page you run the above piece of code . Firstly store all the product info that would like to use in a variable . The you can assign those values the profile mbox parameters.

For Eg.
const productID="12345"; //this is the productID you have

now use this value as mbox profile parameter value :

adobe.target.getOffer({
"mbox": "localMbox",
"params": {
"profile.pdId": productID

},
"success": function(offer) {
adobe.target.applyOffer( {
"mbox": "localMbox",
"offer": offer
} );
},
"error": function(status, error) {
console.log('Error', status, error);
}
});


If you can see this value firing on 1st page, then for 2nd page you can create the audience using "visitor profile > pdID > contains > 12345" and use this for experience (popup) on 2nd page.

@LordOfTheRings 

Is there no way to actually get that value in the custom code? Like mbox.get('pID') or something, so I can use the data. 
The data I'm saving is related to the specific product, saving things like cost, code, descriptions and then on the pop-up screen currently I read the localStorage and display a popup based on the information in the localStorage.

But If I'm understanding this correctly, your solution would require me to create a 'page' for each unique pop-up, I would potentially be hardcoding all the data on each page for each specific product.

I think I've figured it out. Thanks for the help 🙂

So for anyone else that finds the question:

Once you do the above as stated by @LordOfTheRings , you can access the value using:

var productId = "${profile.productId}"; // This will parse with the quotes
// OR
var productId = ${profile.productId}; // This will parse it without the quotes.

 

Right @mark , you can use the profile script value like this also Or you can use them while definig audience

Answers (1)

Answers (1)

Amelia_Waliany

Employee

22-04-2020

 Hi @Mark_47

 

Our next Adobe Target Skill Builder Webinar is right around the corner on May 5th, and will be presented by Adobe Target Product Management on migrating Adobe Target’s mbox.js to At.js. Check out this community discussion to register today. Hope you can make it!
 
Warmly,
Amelia