---
title: Web - AJO Code Based Experiences
slug: docs/web-ajo-code-based-experiences
docTags: 
createdAt: 2024-04-10T05:29:59.506Z
---

This section details how to configure AJO Code-based experience in a DSN Web project such as Luma created using the Quick Setup.

### Prerequisites

To showcase the capabilities of the AJO Code-Based Experience, you must ensure that you have met the following prerequisites:

::::VerticalSplit{layout="right"}
:::VerticalSplitItem
- A DSN Web project connected to an AEP Launch tag property


:::

:::VerticalSplitItem


![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/ETQD3EkjvRFWv8zrirkBH_cleanshot-2024-05-03-at-153906.png)
:::
::::

::::VerticalSplit{layout="right"}
:::VerticalSplitItem
- Your data stream should have the Journey Optimizer checkbox checked
:::

:::VerticalSplitItem


![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/qfkxIJmzSnLHz6kzFzstS_cleanshot-2024-05-03-at-152221.png)
:::
::::

### &#xA;Setup:

### Create a Channel Configuration

1. Navigate to **Channels > Channel Configurations** menu.

- Click **Create channel configuration.**

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/rRs7oXOwdc4F2lfA2mxHL_image.png)

2\. Enter Configuration Details

- Provide a **name** and an optional **description** for the configuration.
- **Note**: Names must start with a letter (A-Z) and can only contain alphanumeric characters, underscores (\_), dots (.), and hyphens (-).



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/pqCfdxd2Sf2fqg_Qr9t_K_image.png)

3\. Choose the **Code-based experience&#x20;**&#x63;hannel for the configuration.

4\. Choose the platform: **Web** where the code-based experience will apply:

- Specify a **Page URL** to target a single page.
- Or, create a **Pages matching rule** to apply changes to multiple URLs that meet the rule. This is useful for making global changes across a website, such as updating a hero banner or adding an image across product pages.

:::hint{type="info"}
**&#x20;Location -&#x20;**<u>**hero-banner**</u>**&#x20;as seen in the screenshot below is the unique identifier for the code-based experience.&#x20;**
:::

###

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/mCdKkpBFJVx7rbvgxlKZh_image.png)

After configuring the settings, submit your changes.

Once completed, you can use your new configuration to create a **code-based experience.**

### Create a new AJO Code-Based Experience Campaign

1. Navigate to Journey Management> Campaigns. Create a Campaign.



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/7KQQmOdMiL7qOtxcFJOA5_image.png)

&#x20;   2\. Select Campaign Type as "Scheduled"



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/WIZoH--eRcKfQNjVJm5CD_image.png)

&#x20;  3\. Define Campaign Properties:&#x20;

- In the **Properties** section, provide a name and description for the campaign.
- Choose Your Audience:
  - In the **Audience** section, click **Select Audience** to choose from the available Adobe Experience Platform audiences.&#x20;
  - In the **Identity namespace** field, select the appropriate namespace to identify individuals in the segment.

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/s6beKqfxyhE4FjvJAqZVN_image.png)

5\. Choose the **Code-Based experience&#x20;**&#x66;or the campaign.

6\. Select or Create a new Configuration

In our case, select an existing code-based experience configuration- **LumaChannelConfigurationCBE**



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/rNH5gAmdpy395F9DEr-wI_image.png)

7\. Enable Additional Delivery Rules (Optional):

- If needed, toggle **Enable additional delivery rules**. You can then click **Edit triggers** to define the events and criteria for message delivery using the rule builder.

Let's keep the triggers empty.

﻿


![](https://images.archbee.com/bAgVaanSi1tFmfc8PghaH/g5YsP0y3Rw_OuKmEwqJx5_image.png?format=webp)

8\. Set your campaign to run on a specific date or recur at regular intervals




![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/-Hf6VN8sxdxIjnnCgitj4_image.png)

9\. Begin creating the content by clicking **Edit content**.



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/hl413yP8R8GSTlLWhZfWv_image.png)

10\. Click on Edit Code on the right to provide content

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/OtPBxjCONpKSBIxNgXLf4_image.png)

11\. Provide content and Click on **Save and close**



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/PKElhViwD9KjzESo9rDZF_image.png)

Sample Content:

```javascript
{
  "title": "Winter Essentials for Men",
  "description": "COZY JACKETS AND STYLISH BOOTS FOR THE COLD SEASON!",
  "link": "https://dsn.adobe.com/web/luma3/men",
  "imageUrl": "https://t3.ftcdn.net/jpg/07/54/72/38/240_F_754723858_vbQJuxgmLCaqRX7RzWVj6GvfjiSwTAHp.jpg",
  "code": "DEFAULT"
}
```

12\. Click on **Review to activate.&#x20;**&#x54;hen Click on **Activate**. The campaign should be live now.



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/02LH7gqmDCnxtuL6soC7P_image.png)

###

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/bfXqMhSmaMemLi1FRKFq1_image.png)

### Update the AEP Data Collection tag property configuration

To display the Code-Based Experience on the DSN web project, you must update the rule in the tag property.

<u>**Update the Tag properly Web view rule**</u>

1. Go to your web project --> integrations and open your Data Collection property

   ![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/uw7tUqzb7TkefcLNqjzaQ_image.png)

3\. Using the menu, click on **Rules**

4\. Click on the rule to edit the configuration. Click on the action - **'Send "PageView" Experience Event'.&#x20;**&#x41;dd a surface under surfaces - for example -web://dsn.adobe.com/luma3/home#hero-banner. When you are using your custom project it would be web://dsn.adobe.com/projectName/page#location. This location needs to match the location specified when creating the channel configuration. &#x20;

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/4CYYJa0LRCNXabltv2P0G_image.png)



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/-XSQj_A_GqxKC_6gjuwo2_image.png)



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/uu2AHk0cAeQoJS570Wpr7_image.png)

5\. Go to rule - Display Offer (Offer Decisioning). Click on the action "Display the offer on page". Open the editor and modify the code.&#x20;

Copy and paste the following code in the Data Collection code editor, make sure t&#x6F;**&#x20;update the ID in the code on lines 27,28 and 29 which should be the same as provided on the website configuration page. In this case, we are using hero-banner**

****

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/2Jx-NYrAVpSsreRhlC7yo_image.png)

```javascript

if (!Array.isArray(event.decisions)) {
  console.log("No personalization decisions");
  return;
}

console.log(
  "Received response from Code Based Experience",
  event.decisions
);

event.decisions.forEach(function (payload) {
  if (!Array.isArray(payload.items)) {
    return;
  }

  payload.items.forEach(function (item) {
    if (!item.data || !item.data.content) {
      return;
    }

    var content = item.data.content;

    console.log("Offer", content);

    // Get elements
    var container = document.querySelector(".hero > div.Image");
    var titleElement = document.querySelector(
      ".hero > .Banner__content > div > .Title__content > strong"
    );
    var descriptionElement = document.querySelector(
      ".hero > .Banner__content > div > .Title__content > h1"
    );

    // Update title
    if (titleElement) {
      titleElement.innerText = content.title || "";
    }

    // Update image
    if (container && content.imageUrl) {
      var image = document.createElement("img");

      image.setAttribute("src", content.imageUrl);
      image.setAttribute("alt", content.title || "");

      container.appendChild(image);
    }

    // Update description
    if (descriptionElement) {
      descriptionElement.innerText = content.description || "";
    }
  });
});


```

### Configure Website for Code Based Experience

1. Open web project in builder configuration.
2. Navigate to the Home screen(or any screen)
3. Add module - **Banner&#x20;**&#x75;nder General categor&#x79;**.**
4. Click on the component and open the right sidebar. In th&#x65;**&#x20;Styles&#x20;**&#x73;ection - provide value for Custom CSS Classes as **hero-banner**.&#x20;

:::hint{type="info"}
The class name must match the ID used in the script code mentioned above.
:::



![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/MhR7UvGv8_eHzgEoIOfRv_image.png)

&#x20; 5\. Open the website. Navigate to the home screen. The Code-Based Experience should be rendered in the place where you have added the banner.

![](https://api.archbee.com/api/optimize/bAgVaanSi1tFmfc8PghaH/-8oAgxOr1Mtk-4-Iz3bVC_image.png)

You have successfully configured a working setup that can be customized as per your demonstration requirements.



Live demo of Web AJO Code-Based Experiences:

- **SecurFinancial ATM Screen**: [[https://dsn.adobe.com/docs/atm-screen-code-based-experience](https://dsn.adobe.com/docs/atm-screen-code-based-experience)](https://dsndocs.adobe.com/docs/atm-screen-code-based-experience)
- &#x20; **Binji SSR TV app**: [[https://dsn.adobe.com/docs/binji-tv-ssr-app-code-base-experience](https://dsn.adobe.com/docs/binji-tv-ssr-app-code-base-experience)](https://dsndocs.adobe.com/docs/binji-tv-ssr-app-code-base-experience)



