Overview of steps
Suppose a user enters a URL into a browser which sends a request to your web server. When fulfilling that request:
-
The server reads the visitor and target cookies from the request.
-
The server makes a call to the
getOffersmethod of the Target SDK, specifying the visitor and target cookies if available. -
When the
getOfferscall is fulfilled, values fortargetCookieandvisitorStatefrom the response are used.- A cookie is set on the response with values taken from
targetCookie. This is done using theSet-Cookieresponse header, which tells the browser to persist the target cookie. - An HTML response is prepared that initializes
VisitorAPI.jsand passes invisitorStatefrom the target response.
- A cookie is set on the response with values taken from
-
The HTML response is loaded in the browser…
VisitorAPI.jsis included in the document header.- VisitorAPI is initialized with
visitorStatefrom thegetOffersSDK response. This will cause the visitor cookie to be set in the browser so it will be sent to the server on subsequent requests.
Example code
The following code sample implements each of the steps outlined above. Each step appears in the code as an inline comment next to its implementation.
Node.js
This sample relies on express, a Node.js web framework.
Java
This sample uses spring, a Java web framework.
For more information about TargetRequestUtils.java, see Utility Methods (Java)
Was this content helpful?
Announcements
Get hands-on with agentic AI.
Explore how AI agents work together through real examples and hands-on practice. Join your local User Group to design an agent workflow with your peers and leave with a practical framework you can apply to your own work.
Find an eventAdobe Target Roadmap Webinar - Americas & EMEA
Preview the Adobe Target roadmap and ask the product team your questions live.
Adobe Target Roadmap Webinar - Americas & APAC
Preview the Adobe Target roadmap and ask the product team your questions live.