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

different behavior of adobe.target.applyOffer 1.x vs 2.x

perrin_ennen
Level 3
Level 3

The adobe.target.applyOffer function is used inside the adobe.target.getOffer function.

In at.js 1.x I could still set e.g. "action" with e.g. "replaceContent" in the offer option.

 

If I try the same with at.js 2.x - it doesn't work. If I remove the "action" - then it also works with the at.js 2.x for me.

In source code I also found "replaceContent" with the 2.x - and it should actually work, because the applyOffer function was not changed.

 

Does anyone know the problem? Is it really because of this function? What am I doing wrong? Or is the problem something completely different?

 

Best regards
Perrin

1 Accepted Solution
Pawan_Gupta_
Correct answer by
Community Advisor
Community Advisor
0 Replies
Pawan_Gupta_
Correct answer by
Community Advisor
Community Advisor
perrin_ennen
Level 3
Level 3
That the adobe.target.getOffer() and adobe.target.getOffers() are different is clear to me. But the adobe.target.getOffer() at.js 1.x and adobe.target.getOffer() at.js 2.x - should not really change anything. Nevertheless, if I include in the offer Object an also action with "replaceContent" - target replaces the selector only in the at.js 1.x. In at.js 2.x I see also the response - it seems that the adobe.target.applyOffer has a problem with it in at.js 2.x
perrin_ennen
Level 3
Level 3

Here is a sample code - which works for me accordingly in at.js 1.x - but not in at.js 2.x. If I would remove the action parameter - then it works accordingly in both.

 

var mbox = 'mboxName';
var selector = document.querySelector('.className');

adobe.target.getOffer({
    mbox: mbox,
    success: function (response) {
        adobe.target.applyOffer({
            mbox: mbox,
            offer: [{
                content: response[0].content,
                action: 'replaceContent'
            }],
            selector: selector
        });
    },
    error: function (status, errorMsg) { 
        console.log(status, errorMsg);
    }
});