> ## 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.

# Processing offline goal conversions in experiments

> Send offline conversion events such as in-store purchases to Kameleoon using the Data API Visit endpoint and verify their ingestion.

As [previously explored](https://docs.kameleoon.com/developer-docs/apis/data-api-rest/tutorials/storing-and-retrieving-external-data-to-target-users.md), Kameleoon’s DATA API allows users to fetch and write data to Kameleoon servers. Three key endpoints facilitate this: **Visit**, **Product Recommendation**, and **Map**.

In some situations, you must send goal conversion events that occurred offline, such as in-store transactions or over-the-phone transactions, to Kameleoon. The Visit endpoint, described in this tutorial, posts offline data for individual visitors.

In contrast to the MAP endpoint, which offers greater flexibility in the structure of submitted data, the **Visit** endpoint only allows for the submission of predefined data points. These include conversions, events, and page view events, along with several [other types](https://docs.kameleoon.com/user-manual/experiment-analytics/analyze-results/results-page/results-page-settings.md#audience) of data. This information helps filter and analyze experiment results effectively.

This article discusses the following operations:

* Sending offline goal conversions using the [POST/visit/events](https://docs.kameleoon.com/api-reference/visit/send-visitor-events.md) endpoint.
* Verifying the transmission of offline goal data using the [GET/visit/visitor](https://docs.kameleoon.com/api-reference/visit/get-visitor-data.md) endpoint.

To transmit offline conversion data to the Kameleoon server, send a POST request correctly formatted with the **siteCode** and the **visitorCode**:

```shell theme={null}
https://eu-data.kameleoon.io/visit/events?siteCode=example_sitecode&visitorCode=example_visitor_code
```

> [!NOTE]
>
> The domain for Kameleoon scripts may vary by project. Depending on the creation date, Kameleoon hosts projects on either `kameleoon.eu` or `kameleoon.io`. Use the domain in the installation snippet on your project's **Setup** tab in the Kameleoon app. For North America, use `na-data.kameleoon.io` or `na-data.kameleoon.eu`.

* **`siteCode`**: A unique ID associated with the experiment project. Instructions for retrieving this code are available at [Find the siteCode](https://docs.kameleoon.com/user-manual/project-management/manage-your-projects.md#how-do-i-find-my-sitecode).
* **`visitorCode`**: A unique string assigned to each user browsing the app. It assigns users to experiments and variations while tracking their data for reporting. For Kameleoon Web Experimentation, the visitor code is randomly generated and assigned to each user. For Kameleoon Feature Experimentation, the Web SDK generates the visitor code, or you can use a custom ID, particularly for websites requiring login.

> [!NOTE]
>
> Projects utilizing Kameleoon’s cross-device reconciliation can use the `mappingIdentifier` parameter instead of the **`visitorCode`**. Read [more here](https://docs.kameleoon.com/developer-docs/cross-device-experimentation.md).

> [!NOTE]
>
> This endpoint supports bulk conversions for multiple `visitorCode`s. To do this, include each event in the request body.

Required parameters for the request body when sending goal data include:

* **`nonce`:** A random string of 16 hexadecimal characters unique to each event.
* **`eventType`:** A string specifying the event type. Use `CONVERSION` for this example.
* **`goalID`:** The unique ID of the goal. [This article](https://docs.kameleoon.com/user-manual/assets/goals/manage-goals.md) explains how to access and manage goals.
* **`revenue`:** An optional float parameter indicating the revenue generated during the conversion.

This information translates to the following cURL request:

```shell theme={null}
curl -X POST 'https://eu-data.kameleoon.io/visit/events?siteCode=f17c21u1ag&visitorCode=245fc&json=true' \
-H 'Content-Type: application/json' \
-H 'User-Agent: CustomUserAgent/1.0' \
-d '[{"nonce":"a2bb4d22083348ef","eventType":"CONVERSION","goalId":36151,"revenue":23.50}]'
```

Since a successful request provides no object response, the next section demonstrates how to verify success using the [GET/visit/visitor](https://docs.kameleoon.com/api-reference/visit/get-visitor-data.md) endpoint.

## Verifying offline goal conversion data

Use the [GET endpoint](https://docs.kameleoon.com/api-reference/visit/get-visitor-data.md) to verify the result of the POST request.

The request URL must include:

* **`siteCode`:** The unique ID of your project. See [Find the siteCode](https://docs.kameleoon.com/user-manual/project-management/manage-your-projects.md#how-do-i-find-my-sitecode) for instructions on retrieving it.
* **`visitorCode`:** The same visitor code that you used in the POST request.
* **`maxNumberPreviousVisits`:** An integer representing the maximum number of previous visits to return.
* **`currentVisit`:** Set to `true` to focus on the current visit; the default value is `false`. ***(Note: This parameter is only available for Kameleoon Feature Experimentation.)***
* **`conversion`:** Set to `true` to retrieve conversion events for the specified user and goals configured in the Kameleoon account.

> [!NOTE]
>
> If Feature Experimentation isn't active, wait until Kameleoon processes the visit, usually after 30 minutes of inactivity. The conversion data then appears in the last computed previous visit.

This translates to the following cURL request:

```shell theme={null}
curl -X GET 'https://eu-data.kameleoon.io/visit/visitor?siteCode=f17c21u1ag&visitorCode=245fc&maxNumberPreviousVisits=5&currentVisit=true&conversion=true' \
-H 'Content-Type: application/json' \
-H 'User-Agent: CustomUserAgent/1.0' \
```

A successful GET request returns a response containing the data sent in the previous request, confirming that the POST request was successful:

```json theme={null}
{
  "previousVisits": [
    {
      "siteCode": "f17c21u1ag",
      "visitorCode": "245fc",
      "timeStarted": 1740447713028,
      "conversionEvents": [
        {
          "itp": false,
          "time": 1740447713028,
          "data": {
            "goalId": 361517,
            "revenue": 23.50,
            "negative": false,
            "metadata": {}
          }
        }
      ]
    }
  ]
}
```

## Additional information

In most cases, experiment reports use conversions for a specified goal and visitor. Kameleoon links conversions to experiments based on several rules:

* **Conversions during active visits:** If a conversion occurs while the visitor is active and targeted by an experiment, Kameleoon links the conversion to the experiment for that visit.
* **Conversions after visits end:** If a visitor was previously included in an experiment but later makes a purchase through a different channel (for example, by phone or in-store), Kameleoon attributes that conversion to the experiment if it occurs within the defined attribution window (default: 7 days). Kameleoon creates a new visit associated with the conversion in this scenario.

Analyzing data at the visitor level provides a complete view of conversions, including those occurring during non-targeted visits, provided an experiment previously targeted the visitor. See [How Kameleoon counts conversions](https://docs.kameleoon.com/user-manual/experiment-analytics/analyze-results/data-and-metrics/how-kameleoon-counts-conversions.md) for more information.
