> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Adobe Audience Manager

> Use Adobe Audience Manager segments as targeting conditions in Kameleoon by creating a cookie destination and syncing audience data.

With the Adobe Audience Manager integration, you can build unique audience profiles to identify your most valuable segments and use them in Kameleoon to create highly personalized campaigns.

To use this integration, you need Administrative permissions in AAM, as you must create a Kameleoon destination, so Kameleoon can retrieve segment details (segment name and ID) from AAM.

## Set up a Kameleoon Destination in Adobe Audience Manager

First, you must create a Kameleoon destination in AAM:

1. Click **Manage Data** > **Destinations** and create a new [Cookie destination](https://experienceleague.adobe.com/docs/audience-manager/user-guide/features/destinations/custom-destinations/create-cookie-destination.html?lang=en) with the following settings:
   * **Name**: Kameleoon
   * **Type**: Cookie
   * **Auto-fill Destination Mapping**: Segment ID
2. Click **Next**. The **Configuration** settings open.
   * **Cookie Name**: The value of this field must be **`aamkamsegs`** (please do not change this, as it will prevent the integration from working).
   * **Cookie Domain**: Enter all domains where the `amkamsegs` cookie should be created. We recommend indicating your main domain in this field: `mymaindomain.com`. To learn more about this, read this [article](https://experienceleague.adobe.com/docs/audience-manager/user-guide/features/destinations/custom-destinations/cookie-destination-options.html?lang=en).
   * **Data format option**: Set the data format as [**Serial single key**](https://experienceleague.adobe.com/docs/audience-manager/user-guide/features/destinations/destinations-reference/key-value-pairs.html?lang=en) (with the following properties):
     * **Key**: `aam_segs_`
     * **Key-Value Pair Delimiter**: should be a colon "**:**"
     * **Serialize**: uncheck the **Enabled** option.
3. Click **Save** to add the Kameleoon destination to your AAM account.

## Choose the AAM segments you want to use with Kameleoon

Once you create the Kameleoon destination, you can choose the AAM segments you want to use with Kameleoon:

1. Go to **Manage Data > Segments** and select the segments you want to use with Kameleoon.
2. Click **Add to Destination** and select the Kameleoon destination.
3. Click **Save**.

To view all segments that are available in Kameleoon, navigate to **Manager Data** > **Destinations** and select the Kameleoon destination. Ensure the **Mapping** column contains values like `aamseg=ID of the segment`. If this is not the case, please contact your AAM Customer Success Manager.

## Set up a Kameleoon Custom Data to use AAM segments

To use your AAM segments in our Segment builder, you must set up a [custom data](../../../assets/custom-data/create-custom-data) in your Kameleoon account. You can choose your custom data's name (for example, Adobe Audience Manager Segments). Follow the steps below (settings must be configured exactly as written):

* **Acquisition method** : Custom JavaScript Code. Copy and paste the code below in the custom code section of the custom data as below.

```javascript theme={null}
 function getCookie(cname) {
   var name = cname + "=";
   var decodedCookie = decodeURIComponent(document.cookie);
   var ca = decodedCookie.split(';');
   for(var i = 0; i <ca.length; i++) {
     var c = ca[i];
     while (c.charAt(0) == ' ') {
       c = c.substring(1);
     }
     if (c.indexOf(name) == 0) {
       return c.substring(name.length, c.length);
     }
   }
   return null;
 }
 var aam_segments = getCookie("aamkamsegs");
 if (aam_segments && aam_segments!= "" && aam_segments!= " "){
 aam_segments = aam_segments.split("=");
 if(aam_segments.length > 0){
 aam_segments = aam_segments[1];
 aam_segments = aam_segments.split(",");
 return {"value": aam_segments, "overwrite": true};
 }
 }
```

* **Type**: List of strings
* **Scope**: Page

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/cdp/adobe-audience-manager/image1-1-1920x998.png)
</Frame>

For each user that visits your site, Kameleoon will automatically check the presence of the **`aamkamsegs`** cookie and fill the custom data with the AAM segments for which the current user qualifies. If a Kameleoon campaign runs on your project for a given AAM segment, Kameleoon will determine, in real-time (with no network request to an AAM API endpoint), the user's eligibility, and display the campaign accordingly.

## Fetch AAM segments' names in Kameleoon

The AAM mapped segments' names can be retrieved via the AAM REST API, so when you use the custom data in Kameleoon's Segment builder, you can use the AAM segment name instead of the segment ID.

When you open the Kameleoon Segment builder, Kameleoon makes an authenticated request to the [`https://api.demdex.com/v1/destinations/destinationId/mappings`](https://bank.demdex.com/portal/swagger/index.html#/Destination%20API/get_destinations__destinationId__mappings_) endpoint, where the **`destinationId`** is replaced with the ID corresponding to the Kameleoon Destination you created.

For each mapped segment, Kameleoon retrieves the segment name (`elementName`) and the segment ID (`sid`). The segment name is then available from the Kameleoon Segment builder when you use the custom data.

To set up this feature, please contact your Kameleoon Customer Success Manager; you must provide authentication credentials, as explained in this [article](https://www.adobe.io/developer-console/docs/guides/authentication/JWT/).

## Use an AAM segment in Kameleoon Segment Builder

Once the custom data for AAM segments is set up in Kameleoon, you can build segments within the Kameleoon Segment builder by choosing the segment IDs you would like to target with your campaign **OR** choosing the option **is among the values**, which will then show a list of every segment for your Kameleoon Destination.
