> ## 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](./storing-and-retrieving-external-data-to-target-users), 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, goal conversion events that occurred offline, such as in-store transactions or over-the-phone transactions, must be sent 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](/user-manual/experiment-analytics/analyze-results/results-page-settings#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](/api-reference/visit/send-visitor-events) endpoint.
* Verifying the transmission of offline goal data using the [GET/visit/visitor](/api-reference/visit/get-visitor-data) 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, projects are hosted on either `kameleoon.eu` or `kameleoon.io`. Use the domain displayed in the project settings in the Kameleoon App. For North America, use `na-data.kameleoon.io` or `na-data.kameleoon.eu`.
</Note>

* **`siteCode`**: A unique ID associated with the experiment project. Instructions for retrieving this code are available at [this link](/user-manual/faq#how-do-i-find-my-sitecode).
* **`visitorCode`**: A unique string assigned to each user browsing the application. 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 a custom ID can be used, 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](../../../cross-device-experimentation).
</Note>

<Note>
  This endpoint supports bulk conversions for multiple `visitorCode`s. To do this, include each event in the request body.
</Note>

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](/user-manual/assets/goals/manage-goals) 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](/api-reference/visit/get-visitor-data) endpoint.

## Verifying offline goal conversion data

Use the [GET endpoint](/api-reference/visit/get-visitor-data) to verify the result of the POST request.

The request URL must include:

* **`siteCode`:** See the [previous section](#sending-offline-goal-conversion) for instructions on retrieving this code.
* **`visitorCode`:** The same visitor code used in the [previous section](#sending-offline-goal-conversion).
* **`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 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 is not active, wait until Kameleoon processes the visit, usually after 30 minutes of inactivity. The conversion data then appears in the last computed previous visit.
</Note>

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:

```shell 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, conversions for a specified goal and visitor are used in experiment reports. 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 (e.g., by phone or in-store), Kameleoon attributes that conversion to the experiment if it occurs within the defined attribution window (default: seven 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 [this link](/user-manual/experiment-analytics/analyze-results/how-kameleoon-counts-conversions) for more information on how Kameleoon counts conversions.
