# API campaigns creation

Created: 26.04.2023

Updated: 08.11.2023

Author: Anastasia N.

{% hint style="info" %}
General description of campaign structure in the platform: [Campaigns structure](/lang/en/platform-interface/campaigns-structure.md)
{% endhint %}

## **Creating an API Campaign**

<figure><img src="/files/6fW3aU0FhuObclczpLkI" alt=""><figcaption></figcaption></figure>

When you click the "Create Campaign" button on the main screen, a new screen will open. Here you can configure your future campaign:

1. Rename the campaign.
2. Include a text comment (describing the campaign) and labels (for example, for categorizing campaigns by page type).
3. Change the campaign status.&#x20;

&#x20;     The status can be Active, Draft, or Paused.

4. Specify the campaign selector, which you will later use in <mark style="color:red;">**`choose`**</mark> requests.
5. Specify the selector group name (it allows to call all selectors belonging to a group within a single <mark style="color:red;">**`choose`**</mark> request without listing each of them separately).
6. Choose the campaign type — Custom JSON or Recommendations.
7. Cancel or save changes.
8. Edit, duplicate, or delete experiences within the campaign.

## **Working with Experiences**

<figure><img src="/files/gEYTQEeGMzx9HTaKaNdJ" alt=""><figcaption></figcaption></figure>

On the experience creation screen, you can:

1. Provide an experience name.
2. Navigate to the subsection for creating variations and change the experience status.
3. Specify targeting conditions. More details: [Targeting conditions definition and their applicability.](/lang/en/general-information/targeting-conditions-definition-and-their-applicability.md)
   1. Time targeting: when configuring targeting conditions, you can additionally specify the time and/or day of the week required for the user to fall into targeting. Additional intormation can be found by the link: [Targeting conditions definition and their applicability](/lang/en/general-information/targeting-conditions-definition-and-their-applicability.md#when)
4. Save or discard changes.

## Campaign Planning

To set a specific time frame for the experience, click "Set Schedule" in the field of the relevant experience:

<figure><img src="/files/6HHNuhPAAbFUjSbM09wM" alt=""><figcaption></figcaption></figure>

![](/files/krVT1wQuicrtRZE1oTxz)![](/files/LLgplLC2QyFrKOqnZ0Pq)

In the opened pop-up, you can choose the:

1. Start and end date of the experience;
2. Exact start and end time of the experience;
3. Timezone - either section's or user's.

When choosing the start and end dates for the experience, select the desired date in the displayed calendar.

## **Creating a Variation**

<figure><img src="/files/HYTTScMIJENFbK5xXD5K" alt=""><figcaption></figcaption></figure>

On the variations screen, you can:

1. Choose a testing method: A/B testing or Dynamic Allocation.

{% hint style="info" %}
Dynamic Allocation is a mode in which the system automatically determines the percentage of users exposed to a specific variation. The variation that shows the best results in terms of the assigned primary metric is shown to a larger percentage of users. Dynamic Allocation aims to achieve maximum impact in the shortest possible time with an emphasis on achieving results quickly.
{% endhint %}

2. Select the primary metric:

<div align="left"><figure><img src="/files/wl7suYqynRmT3PzWsMly" alt="" width="171"><figcaption></figcaption></figure></div>

3. Modify additional experience settings: variation selection frequency for users as well as start and end of the attribution window.

<div align="left"><figure><img src="/files/Pq0ww19iujoBich8dWR8" alt="" width="285"><figcaption></figcaption></figure></div>

{% hint style="info" %}
The attribution window is a period during which all conversions and revenue from a user will be attributed to the specific variation.

Example: if the variation's attribution window is set to 3 days and the start of the attribution window is set to the variation is served, then the purchase event of a user who visited the site on March 1st, saw the variation, and made a purchase on March 2nd, will be attributed to the variation he was exposed to.
{% endhint %}

4. Click "Add New Variation" button to create a variation either from scratch or by using existing [templates](/lang/en/platform-interface/working-with-templates.md).
5. Set the weight of the variation. The sum of the weights specified for variations should always be 100%.

{% hint style="info" %}
Example: if the campaign has two variations with a weight of 50% each, it means that one half of the audience will see the first variation, and the other half will see the second.
{% endhint %}

6. Clicking the "pencil" icon enters variation editing mode.
7. Clicking the "three dots" icon opens an additional menu allowing you to duplicate or delete the variation.

<div align="left"><figure><img src="/files/Ux9tDgca3jLGfVEwUeBc" alt="" width="93"><figcaption></figcaption></figure></div>

8. Clicking the "Cancel" button cancels the changes you’ve made, clicking the "Save Experience" button saves the changes you’ve made (please note that no changes are saved in a campaign unit you save or publish the campaign).

## **Creating and Editing Variation Code**

<div align="left"><figure><img src="/files/qcbkRS4rGmwT50dzYldY" alt=""><figcaption></figcaption></figure></div>

On the variation editing screen, you can:

* In **Custom JSON** campaigns, specify custom JSON. It will be passed in an API-call in response to a request to <mark style="color:red;">`choose`</mark> endpoint.
* In **Recommendations** campaigns, choose a recommendation strategy and specify custom JSON.

You can also set the parameters as variables and use them within the campaign. Variables make it easier to configure campaigns and allow business users to customize campaigns without the need for developers, providing them the ability to replace text, images, colors, and other design element parameters directly from the platform interface. More details [Working with Variables in Variations](/lang/en/platform-interface/working-with-variables-in-variations.md)

## **Changing Experience Status**

After making all necessary changes, as well as while working with the campaign in general, you can change the experience status:

* Draft
* Active
* Paused

<figure><img src="/files/JUWiYmiFLuPAaYVGTgLW" alt=""><figcaption></figcaption></figure>

## Saving the campaign

Don’t forget to save the campaign by clicking the “Publish” button at the bottom of the page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.gravityfield.ai/lang/en/platform-interface/api-campaigns-creation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
