Skip to main content

Processing offline goal conversions in experiments

As previously explored, 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 of data. This information helps filter and analyze experiment results effectively.

This article discusses the following operations:

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

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.

  • siteCode: A unique ID associated with the experiment project. Instructions for retrieving this code are available at this link.
  • 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.

note

This endpoint supports bulk conversions for multiple visitorCodes. 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 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:

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

Verifying offline goal conversion data

Use the GET endpoint to verify the result of the POST request.

The request URL must include:

  • siteCode: See the previous section for instructions on retrieving this code.
  • visitorCode: The same visitor code used in the previous section.
  • 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.

This translates to the following cURL request:

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:

{
"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 for more information on how Kameleoon counts conversions.