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

getoffers/applyoffers - prefetch vs execute

Avatar

Level 2

Hi All,

I want to implement getoffers/applyoffers on my website (non SPA) but need to understand terminology use in implementation

In getoffers()/applyoffers() I can use any one of the below functionality in implementing the code

Request > prefetch vs Request > execute

I need to understand

1) the difference between both the functionality (prefetch vs execute)

2) When to use either of them

3) How it will impact the delivery

4) Can we use it in combination like in getoffers() I use (prefetch) and in applyoffers() I use (execute)

 

 I have read Adobe document but it didn't  clear  my questions

experienceleague.adobe.com/docs/target/using/implement-target/client-side/at-js-implementation/functions-overview/adobe-target-getoffers-atjs-2.html?lang=en 

 

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @avez 

Hope you read the how at.js works at client side. Just to give you little context 

Adobe Target at.js 2.x uses new API called Delivery API to retrieve optimized and personalized content from Target and showing to end user. 

This API is based on REST - ( if you not sure about rest then this guide will help What is REST? ). 

 

Prefetch -> It allows clients like mobile apps and servers to fetch content for multiple mboxes or views(for Single page Application) in one request, cache it locally, and later notify Target when the user visits those mboxes or views. 

 

Execute -> The execute part of the request that will be evaluated on the server side immediately.

(Rendering part).

 

The prefetch mode can only be used for AB and XT activities. 

 

you can able to see the network call in your browser like below or filter out with delivery 

at.js 2.x - http://<client code>.tt.omtrdc.net/rest/v1/delivery

 

When you used prefetch, in response you can see content field contain the experience to show the user for a particular mbox. This is very useful when cached on your server so that when a user interacts with your web or mobile application within a session and visits an mbox on any particular page of your application, the experience can be delivered from the cache instead of making another Adobe Target Delivery API call. However, when an experience is delivered to the user from the mbox, a notification will be sent via a Delivery API call in order for impression logging to occur. This is because the response of prefetch calls are cached, which means that the user has not seen the experiences at the time the prefetch call happens.

 

I would recommend to read more about delivery api. 

 

Hope this helps. 

View solution in original post

4 Replies

Avatar

Community Advisor

Hi @avez 

adobe.target.getOffers(options) and adobe.target.applyOffers(options) both the functions introduced in at.js 2.x version. 

 

Ideally, when you're trying to setup any experience on your website through adobe target, you need to implement at.js, I would suggest please check how at.js works and it's architecture. 

 

When you called getOffer() or getOffers() that means you're prefetching the offer from Target and you'll get the response once the request successfully made. 

Once you have the response then call either applyOffer() or applyOffers() for rendering or executing that offer on the page or use your own custom success handle function. 

 

please see below example. 

 

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); 
  } 
});

using Custom success call, 

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 
}); 

Note: getOffer() is used for single mbox request and getOffers() is used for multiple mbox request in same call and same for applyOffer.  

 

Hope this helps.

Avatar

Level 2

Hi Gokula

 

Thanks for the reply. But this is not what i am looking for.

 

What I am looking here is difference between 
Request > prefetch vs Request > execute in getoffers()/applyoffers()

Also, how it will impact activity content delivery.

1) the difference between both the functionality (prefetch vs execute)

2) When to use either of them

3) How it will impact the delivery

4) Can we use it in combination like in getoffers() I use (prefetch) and in applyoffers() I use (execute)

 

I have seen few examples were code is using Request > prefetch in both getoffers()/applyoffers() same time and 

few examples using Request > execute in both getoffers()/applyoffers() same times

 

Avatar

Correct answer by
Community Advisor

Hi @avez 

Hope you read the how at.js works at client side. Just to give you little context 

Adobe Target at.js 2.x uses new API called Delivery API to retrieve optimized and personalized content from Target and showing to end user. 

This API is based on REST - ( if you not sure about rest then this guide will help What is REST? ). 

 

Prefetch -> It allows clients like mobile apps and servers to fetch content for multiple mboxes or views(for Single page Application) in one request, cache it locally, and later notify Target when the user visits those mboxes or views. 

 

Execute -> The execute part of the request that will be evaluated on the server side immediately.

(Rendering part).

 

The prefetch mode can only be used for AB and XT activities. 

 

you can able to see the network call in your browser like below or filter out with delivery 

at.js 2.x - http://<client code>.tt.omtrdc.net/rest/v1/delivery

 

When you used prefetch, in response you can see content field contain the experience to show the user for a particular mbox. This is very useful when cached on your server so that when a user interacts with your web or mobile application within a session and visits an mbox on any particular page of your application, the experience can be delivered from the cache instead of making another Adobe Target Delivery API call. However, when an experience is delivered to the user from the mbox, a notification will be sent via a Delivery API call in order for impression logging to occur. This is because the response of prefetch calls are cached, which means that the user has not seen the experiences at the time the prefetch call happens.

 

I would recommend to read more about delivery api. 

 

Hope this helps.