Using adobe.target.getOffer, success or failure doesn't console.log anything. All relevant offers have been configured. Please see what the problem is, thanks a lot.
console.log('getOffer begin:') is printed, but the success or error console is not executed.
console.log("getOffer begin:");
adobe.target.getOffer({
"mbox": "locationA",
"success": function(offer) {
adobe.target.applyOffer({
"mbox": "locationA",
"offer": offer
});
console.log("Get offer success : ", offer);
},
"error": function(status, error) {
console.log('Error', status, error);
},
"timeout": 3000
});
Solved! Go to Solution.
Hello @yan_yan,
Here is also an overview of how I created a test activity for it:
Location 1
target-global-mbox
Content
<script>
adobe.target.getOffer({
"mbox": "locationA",
"success": function (offer) {
if (offer.length) {
adobe.target.applyOffer({
"mbox": "locationA",
"offer": offer
});
console.log("Get offer success : ", offer);
} else {
console.log('Offer not available');
}
},
"error": function (status, error) {
console.log('Error', status, error);
},
"timeout": 3000
});
</script>
Location 2
locationA
Content
<script>console.log("Offer locationA")</script>
-> Console Output:
If there was no offer or default content stored for location 2 - it would look like this in the console:
-> Console Output:
Hope this helps you.
Best regards
Hello @yan_yan,
I recommend to check the offer again if the e.g. is empty - can also be checked more precisely. But here is an example of what I mean:
adobe.target.getOffer({
"mbox": "locationA",
"success": function (offer) {
if (offer.length) {
adobe.target.applyOffer({
"mbox": "locationA",
"offer": offer
});
console.log("Get offer success : ", offer);
} else {
console.log('Offer not available');
}
},
"error": function (status, error) {
console.log('Error', status, error);
},
"timeout": 3000
});
You can of course check with offer[0].content - even more - if desired. But basically you can see here if the expected offer arrives at all.
Hope this helps you.
hi @Perrin_Ennen ,
Thank you for your reply. I tried, but I still can't print the console in Success or Failure.
Hello @yan_yan,
Here is also an overview of how I created a test activity for it:
Location 1
target-global-mbox
Content
<script>
adobe.target.getOffer({
"mbox": "locationA",
"success": function (offer) {
if (offer.length) {
adobe.target.applyOffer({
"mbox": "locationA",
"offer": offer
});
console.log("Get offer success : ", offer);
} else {
console.log('Offer not available');
}
},
"error": function (status, error) {
console.log('Error', status, error);
},
"timeout": 3000
});
</script>
Location 2
locationA
Content
<script>console.log("Offer locationA")</script>
-> Console Output:
If there was no offer or default content stored for location 2 - it would look like this in the console:
-> Console Output:
Hope this helps you.
Best regards
Hi @yan_yan , thanks for your question!
Did you find @Perrin_Ennen's answer helpful? If so please feel free to mark his reply as "Correct" and/ or follow up with a question or more context
Views
Replies
Total Likes
Views
Like
Replies
Views
Likes
Replies