Skip to main content

POST /visit/events

POST 

/visit/events

This endpoint can be used to post data for a given visitor, such as conversion events, page view events etc.

An incoming request is rejected if the source is identified as bot or spider, according to user-agent filtering rules from IAB/ABC. Kameleoon is using single-pass method. This means nothing specific is to be done in the case request is sent from a web browser using a standard library (XHR); but in other cases the user should set a custom value to the User-Agent request header, to overwrite the default value set by the library.

Request

Query Parameters

    siteCode stringrequired

    Id of the Kameleoon project

    visitorCode string

    Visitor code (Kameleoon unique id for a visitor). Note: if the parameter "visitorCode" is provided here, then it is assumed as the common value for all events in the body (bulk posting of several events restricted to the same visitor). On the contrary, if you would like to bulk post several events across several different visitors, then you must provide the parameter "visitorCode" with every event in the body

    json boolean

    Set to true if you provide the body content in JSON format, else URL query format is assumed. See body schema

    Default value: false

Body

required

Events to save. Body size limited to 8 MB.

When the URL query parameter is missing the "json" key or its value is set to false, the body consists of one or more lines, with each line representing an event in a specific format. The format is as follows: <parameter 1 name>=<parameter 1 value>&<parameter 2 name>=<parameter 2 value> and so on. Make sure to escape values that may contain characters = or &, for example using the function encodeURIComponent in JavaScript.

If the URL contains the query parameter "json" with the value set to true, then the body will be a JSON array of events. Each event will be represented as a JSON object, formatted like this: {"<parameter 1 name>": <parameter 1 value>, "<parameter 2 name>": <parameter 2 value>, etc.}.

In all cases, the body will contain the following parameters:

NameTypeRequiredDescription
visitorCodestringRequired if not provided in URL query parameters, else ignoredKameleoon unique id for a visitor
noncestringRequiredA random string of 16 hexadecimal characters, unique to each event
eventTypestringRequiredOne of the following: STATICDATA, PAGE, CONVERSION, TARGETINGSEGMENT, EXPERIMENT, PERSONALIZATION, WEATHER, CUSTOMDATA, PRODUCT, GEOLOCATION

List of parameters for the eventType STATICDATA:

NameTypeRequiredDescription
visitNumberint32OptionalNumber of visits
timeSincePreviousVisitint64OptionalTime since last visit in milliseconds
browserstringOptionalBrowser's name (e.g. "Safari")
browserIndexint32OptionalConfigured browser index
browserVersionfloat64OptionalBrowser version
osstringOptionalOS name (e.g. "Windows")
osIndexint32OptionalConfigured OS index
windowWidthint32OptionalWindow width
windowHeightint32OptionalWindow height
screenWidthint32OptionalScreen width
screenHeightint32OptionalScreen height
timeZoneIdstringOptionalTime zone id (e.g. "Europe/Paris")
localeLanguageTagstringOptionalLocal language tag (e.g. "fr")
deviceTypestringOptionalOne of the following: DESKTOP, TABLET, PHONE

List of parameters for the eventType PAGE:

NameTypeRequiredDescription
herfstringRequiredComplete URL
canonicalHrefstringOptionalCanonical herf
titlestringOptionalPage title
keyPageIndicesJSON arrayOptionalJSON array of configured key page indices (int32)
referrerHrefstringOptionalComplete URL of referrer
referrerIndicesJSON arrayOptionalJSON array of configured referrer indices (int32)

List of parameters for the eventType CONVERSION:

NameTypeRequiredDescription
goalIdint64RequiredId of the goal
revenuefloat64OptionalRevenue generated in the goal
negativeBooleanOptional,
default false
Should conversion be removed?
metadataJSON objectOptionalJSON object with the following structure: key = metadata id (int32), value = metadata values (JSON array of string)

List of parameters for the eventType TARGETINGSEGMENT:

NameTypeRequiredDescription
idint64RequiredSegment id

List of parameters for the eventType EXPERIMENT:

NameTypeRequiredDescription
idint64RequiredExperiment id
variationIdint64RequiredVariation id. 0 if reference

List of parameters for the eventType PERSONALIZATION:

NameTypeRequiredDescription
idint64RequiredPersonalization id
variationIdint64RequiredVariation id. 0 if reference
unexpositionCausestringOptionalOnly valid if variationId is 0. One of the following: GLOBAL_EXCLUSION, PERSONALIZATION_CAPPING, SCHEDULE, PERSONALIZATION_EXCLUSION, VISITOR_CAPPING, SCENARIO, PRIORITY

List of parameters for the eventType WEATHER:

NameTypeRequiredDescription
temperaturefloat64RequiredTemperature in Kelvin
humidityfloat64RequiredHumidity percentage
pressurefloat64RequiredAtmospheric pressure in hPa
windSpeedfloat64RequiredWind speed in meters/second
cloudinessfloat64RequiredCloudiness in percentage
sunriseTimeint64RequiredSunrise time as a UNIX millisecond timestamp
sunsetTimeint64RequiredSunset time as a UNIX millisecond timestamp
weatherCodestringOptionalWeather description (e.g. "Sky is Clear")

List of parameters for the eventType CUSTOMDATA:

NameTypeRequiredDescription
indexint32RequiredConfigured custom data index
valuesCountMapJSON objectRequiredJSON object with the following structure: key = value (string), value = count (int32)
overwriteBooleanOptional,
default true
Overwrite previous values counts (or merge)?
mappingIdentifierBooleanOptional,
default false
Is this custom data used as a mapping identifier?

List of parameters for the eventType PRODUCT:

NameTypeRequiredDescription
eanstringRequiredProduct code

List of parameters for the eventType GEOLOCATION:

NameTypeRequiredDescription
countrystringOptionalCountry
regionstringOptionalRegion
citystringOptionalCity
postalCodestringOptionalPostal code
latitudefloat64OptionalLatitude
longitudefloat64OptionalLongitude

Note: in the examples below, we assume that the parameter "visitorCode" is provided in the URL query part, so this is bulk posting of several events restricted to the same visitor, and then "visitorCode" is not needed in body events.

Body example in the case the URL query parameter "json" is missing or present with value false (NB: https%3A%2F%2Fwww.supersite.com%2Fsuperpage%3Fsuperparam%3Dtrue is the escaped value of https://www.supersite.com/superpage?superparam=true, while %7B%22val1%22%3A1%2C%22val2%22%3A5%7D is the escaped value of {"val1":1,"val2":5}):

nonce=d2ce4d22083348fb&eventType=STATICDATA&browser=Safari&browserVersion=16.3&deviceType=DESKTOP&os=Windows
nonce=b0a4253d8acd01c7&eventType=PAGE&href=https%3A%2F%2Fwww.supersite.com%2Fsuperpage%3Fsuperparam%3Dtrue
nonce=4ca34741a6cc8a48&eventType=CONVERSION&goalId=2&revenue=24.99
nonce=69e2d11c519868cc&eventType=EXPERIMENT&id=5&variationId=0
nonce=9de54e5675f4e18d&eventType=CUSTOMDATA&index=3&valuesCountMap=%7B%22val1%22%3A1%2C%22val2%22%3A5%7D

Body example in the case the URL query parameter "json" is present with value true, with a "pretty" representation (not recommended):

[
{
"nonce": "d2ce4d22083348fb",
"eventType": "STATICDATA",
"browser": "Safari",
"browserVersion": 16.3,
"deviceType": "DESKTOP",
"os": "Windows"
},
{
"nonce": "b0a4253d8acd01c7",
"eventType": "PAGE",
"href": "https://www.supersite.com/superpage?superparam=true"
},
{
"nonce": "4ca34741a6cc8a48",
"eventType": "CONVERSION",
"goalId": 2,
"revenue": 24.99
},
{
"nonce": "69e2d11c519868cc",
"eventType": "EXPERIMENT",
"id": 5,
"variationId": 0
},
{
"nonce": "9de54e5675f4e18d",
"eventType": "CUSTOMDATA",
"index": 3,
"valuesCountMap": {
"val1": 1,
"val2": 5
}
}
]

Body example in the case the URL query parameter "json" is present with value true, with a "compact" representation (recommended):

[{"nonce":"d2ce4d22083348fb","eventType":"STATICDATA","browser":"Safari","browserVersion":16.3,"deviceType":"DESKTOP","os":"Windows"},{"nonce":"b0a4253d8acd01c7","eventType":"PAGE","href":"https://www.supersite.com/superpage?superparam=true"},{"nonce":"4ca34741a6cc8a48","eventType":"CONVERSION","goalId":2,"revenue":24.99},{"nonce":"69e2d11c519868cc","eventType":"EXPERIMENT","id":5,"variationId":0},{"nonce":"9de54e5675f4e18d","eventType":"CUSTOMDATA","index":3,"valuesCountMap":{"val1":1,"val2":5}}]

    string

Responses

URL query was processed successfully and no content is returned
Body will be processed asynchronously, no syntax check on body was done yet

Loading...