AAM segments
Adobe Audience Manager segments can be leveraged via Adobe Target SDKs. In order to leverage AAM segments, the following fields need to be provided:
locationHintmarketingCloudVisitorIdblobThe SDK will automatically populate these fields for you when making a getOffers method call, but you will need to ensure a valid visitor cookie is provided. In order to get this cookie, you need to implement VisitorAPI.js in the browser.
Implementation Guide
Use of Cookies
Cookies are used to correlate Adobe Audience Manager requests with Adobe Target requests. These are the cookies used in this implementation.
AMCVS_XXXXXXXXXXXXXXXXXXXXXXXX%40AdobeOrgVisitorAPI.js when it is initialized with visitorState from the target getOffers response.mboxtargetCookie from the target getOffers response.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.
| code language-js line-numbers |
|---|
|
| code language-html line-numbers |
|---|
|
Java
This sample uses spring, a Java web framework.
| code language-java line-numbers |
|---|
|
| code language-java line-numbers |
|---|
|
| code language-java line-numbers |
|---|
|
| code language-java line-numbers |
|---|
|
For more information about TargetRequestUtils.java, see Utility Methods (Java)