---
title: Embedded ads in Experience
slug: experience/embedded-ads-in-experience
description: There are two ways to create embedded ads in the Purple Experience: Using data sources and using a content body component. This article explains both approaches.
docTags: 
createdAt: 2024-05-17T08:15:59.131Z
---

There are two ways to create embedded ads in Experience:

1. **Using Data Sources**
2. **Using a Content Body Component**

### 1. Using Data Sources

The embedded ad feature allows you to insert ads between elements at specific positions within your data source. You can configure this feature using the 'ad' field. By enabling the 'ad' field, you can set up embedded ads with the following configurations:

- **adId :&#x20;**&#x54;he ID of the ad to be displayed.
- **Interval :&#x20;**&#x54;he number of elements between each ad display.
- **After :&#x20;**&#x54;he number of elements to display before starting to show embedded ads.
- **Indexed :&#x20;**&#x20;If set to true, the ad ID of embedded ads will follow the structure **adId-index**, where **index** represents the number of embedded ads already inserted (default is 0).
- **startIndex :&#x20;**&#x53;pecifies a custom start index instead of the default value of 0.

**Example**

In this example, the first embedded ad will start displaying after 2 contents. Its ID will be **traffective-5**. The second ad will be displayed after 3 more contents, and its ID will be&#x20;

**traffective-6**, and so on.

![](https://api.archbee.com/api/optimize/ygR6KtT9QI_R0u3uKTJsm/Qq2G5j9HggJ1-f9yfI9DB_screenshot-2024-05-21-at-094136.png)

### 2. Using a Content Body Component

This method allows you to insert ads based on the amount of content in the root level of a content body. To configure this, you can use the **embeddedAd** field with the following settings:

- **adOffsetUnit**: Defines the unit for displaying the embedded ad. Possible values are:
  - **WORD**

    : After a specified number of words.
  - **PARAGRAPH**

    : After a specified number of paragraphs.
  - **LETTER**

    : After a specified number of letters.
- **ADS**: Configure the ad to display here, including:
  - **adConfig**

    : Settings for the ad component to display.
  - **counter**

    : Specifies the number of units (WORD, CHARACTER) after which an ad should be displayed.
  - **Indexed**: If set to true, the ad ID will be named based on the index, resulting in an ID structure of **identifier + index**. Defaults to 0.&#x20;
  - **startIndex:&#x20;**&#x20;If **Indexed**
  - &#x20;is set to true, this defines the starting index.

:::hint{type="info"}
Any ad is always inserted between paragraphs. Example: if you set the value for "word" to "1", the ad will not be inserted after the first word, but after the first paragraph.&#x20;
:::

Inside Content Body Component, ads are inserted on the topmost level to prevent interchange with other elements that might contain paragraphs, like Blockquotes and Figures. Those will be ignored when counting paragraphs, too. &#x20;

For the calculation of paragraphs,we fetch all paragraphs, of the post, ignoring any in-between DIV elements. That way we **exclude&#x20;**&#x61;ny \<p> inside of a \<blockquote> or \<figcaption> or whatever, but **include&#x20;**&#x61;ny \<p> within a surrounding container like a group.



**Example**

In this example, the first embedded ad will be displayed after 1000 words (just after the  paragraph when reaching 1000 words). Its ID will be **traffective-3**. The second ad will be displayed after another 1000 words, with its ID being **traffective-4**, and so on. The maximum number of ads to be displayed is 20.a

![](https://api.archbee.com/api/optimize/ygR6KtT9QI_R0u3uKTJsm/XeJnelGNzBDEpPNYdXIXy_screenshot-2024-05-21-at-095111.png)

