Expand my Community achievements bar.

getOffer() code

Avatar

Level 5

Hi everyone!

Just looking for a step-by-step explanation of the getOffer() and applyOffer code.

 

adobe.target.getOffer({   
  "mbox": "target-global-mbox", 
  "params": { 
     "a": 1, 
     "b": 2 
  }, 
  "success": function(offer) {           
        adobe.target.applyOffer( {  
           "mbox": "target-global-mbox", 
           "offer": offer  
        } ); 
  },   
  "error": function(status, error) {           
      console.log('Error', status, error); 
  } 
});

 

I've read the help article here but I could do with some further information. My specific queries are:

  • What does the 'offer' refer to in the success function?
  • Does the code both set profile information as well as deliver content? 

My use case that has caused me to seek help is as follows:

  • I'm updating an Mbox parameter based on a data element change rule using DTM, firing the code above (but with actual Mbox parameters)
  • I'm then using this Mbox parameter to create an audience rule in Target
  • When this Mbox parameter changes to a specific value (and therefore the profile script) I want to deliver a specific Target Experience straight away

Basically, a customer answers a question and based on that answer I want to put them into an audience and change some content on the page at the same time.

What I want to understand is if the code above does all those things at once:

  1. Updates the profile parameter
  2. Evaluates what audience the customer falls into
  3. Delivers the appropriate on page content for that audience

Many thanks!

1 Reply

Avatar

Community Advisor

This is most viewed un-answered question, hence why I'm replying to a 4 year old question

 

Overall the code checks with Target if there's an activity for the page where the request is made. If there is, it will apply the activity. The code itself is typically used if you need to trigger Target outside of a page load.

So your example of a customer answering a question and based on the answer you want to trigger Target again to re-evaluate or give provide a certain experience. And you want to do this without reloading the page.

Another example could be that users enters site, gives consent and instead of reloading the page to fire Target code, you execute the getOffer and applyOffer functions.

 


Basically, a customer answers a question and based on that answer I want to put them into an audience and change some content on the page at the same time.

What I want to understand is if the code above does all those things at once:

  1. Updates the profile parameter
  2. Evaluates what audience the customer falls into
  3. Delivers the appropriate on page content for that audience

Many thanks!


1. Yes, in the params section of the code you can set profile parameters that will update the profile.

2. Yes, by triggering these Target will evaluate in similar way as if the page was reloaded.

3. Yes, if there is an activity and the user qualified for it, then it will deliver it. Be aware that depending on the element being changed and since there is no reload of the page, the user will most likely experience a flicker when Target changes the content.