Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!
SOLVED

getoffer()/applyoffer - YOUR_OWN_CUSTOM_HANDLING_FUNCTION

Avatar

Level 1

Please help me with a sample function that can be used for custom handling function. For example if I want to introduce a new button, how should I write the function using the below code and introduce the button in the offer?

 

adobe.target.getOffer({
"mbox": "target-global-mbox",
"success": function(offer) {
YOUR_OWN_CUSTOM_HANDLING_FUNCTION(offer);
},
"error": function(status, error) {
console.log('Error', status, error);
},
"timeout": 2000
});

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

At a basic level you'll get an array of objects in the offer parameter that's available on success. If it's activities created via VEC, this could contain multiple different modifications (i.e. change button colour, add custom code etc etc) from one or more Target activities. So you'd need logic to parse through that offer array.

With activities created by the Form Composer, it would be more simple because you could define different mbox names for different locations e.g., an mbox called "homepage-hero-button" and then have multiple different experiences (with different audience logic applied) defined in a single activity. 

So if the JSON offer from Target includes buttonColour & buttonText 

alexbishop_0-1679483308627.png

I can then use that to change my button that has a class of ".w3-button" 

alexbishop_2-1679483557857.png

 

Of course in reality you would have some logic to check that the offer array isn't empty, that it contains a content array that isn't empty, the buttonColour property exists etc 

 

 




View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

At a basic level you'll get an array of objects in the offer parameter that's available on success. If it's activities created via VEC, this could contain multiple different modifications (i.e. change button colour, add custom code etc etc) from one or more Target activities. So you'd need logic to parse through that offer array.

With activities created by the Form Composer, it would be more simple because you could define different mbox names for different locations e.g., an mbox called "homepage-hero-button" and then have multiple different experiences (with different audience logic applied) defined in a single activity. 

So if the JSON offer from Target includes buttonColour & buttonText 

alexbishop_0-1679483308627.png

I can then use that to change my button that has a class of ".w3-button" 

alexbishop_2-1679483557857.png

 

Of course in reality you would have some logic to check that the offer array isn't empty, that it contains a content array that isn't empty, the buttonColour property exists etc