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

# Send visitor events

> Post conversion and page view events for a visitor.

Kameleoon rejects an incoming request if the source is a bot or spider, based on [IAB/ABC user-agent filtering rules](https://www.iab.com/guidelines/iab-abc-international-spiders-bots-list/).
Kameleoon uses a single-pass method. You don't need to take specific action when sending requests from a web browser using a standard library (XHR). However, in other cases, set a custom value for the `User-Agent` request header to overwrite the default value the library sets.



## OpenAPI

````yaml /data.api.json post /visit/events
openapi: 3.0.1
info:
  title: Kameleoon Data API
  description: ''
  version: '1.0'
servers:
  - url: https://eu-data.kameleoon.io
  - url: https://na-data.kameleoon.io
  - url: https://eu-data.kameleoon.eu
  - url: https://na-data.kameleoon.eu
security: []
paths:
  /visit/events:
    post:
      tags:
        - Visit
      summary: Send visitor events
      description: >-
        Post conversion and page view events for a visitor.


        Kameleoon rejects an incoming request if the source is a bot or spider,
        based on [IAB/ABC user-agent filtering
        rules](https://www.iab.com/guidelines/iab-abc-international-spiders-bots-list/).

        Kameleoon uses a single-pass method. You don't need to take specific
        action when sending requests from a web browser using a standard library
        (XHR). However, in other cases, set a custom value for the `User-Agent`
        request header to overwrite the default value the library sets.
      operationId: POST /visit/events
      parameters:
        - name: user-agent
          in: header
          required: true
          description: >-
            Not always required. Kameleoon rejects an incoming request if the
            source is a bot or spider, based on [IAB/ABC user-agent filtering
            rules](https://www.iab.com/guidelines/iab-abc-international-spiders-bots-list/).

            Kameleoon uses a single-pass method. You don't need to take specific
            action when sending requests from a web browser using a standard
            library (XHR). However, in other cases, set a custom value for the
            `User-Agent` request header to overwrite the default value the
            library sets.
          schema:
            type: string
            default: kameleoon-docs
        - name: siteCode
          in: query
          description: The Kameleoon project ID.
          required: true
          schema:
            type: string
        - name: visitorCode
          in: query
          description: >-
            The visitor code (a unique Kameleoon ID for a visitor). Note: If you
            provide the <code>visitorCode</code> parameter here, it is assumed
            to be the common value for all events in the body. If you want to
            post several events for different visitors, provide the
            <code>visitorCode</code> with every event in the body.
          schema:
            type: string
        - name: json
          in: query
          description: >-
            Set to <code>true</code> to provide the body content in JSON format;
            otherwise, URL query format is assumed. See the body schema for
            details.
          schema:
            type: boolean
            default: false
      requestBody:
        description: >-
          Save events. The body size limit is 3 MB.<br/><br/>If the
          <code>json</code> query parameter is missing or set to
          <code>false</code>, the body consists of one or more lines. Each line
          represents an event in the following format: <code>&lt;parameter 1
          name&gt;=&lt;parameter 1 value&gt;&amp;&lt;parameter 2
          name&gt;=&lt;parameter 2 value&gt;</code> and so on. Escape values
          that may contain characters <code>=</code> or <code>&amp;</code>, for
          example, using the <code>encodeURIComponent</code> JavaScript
          function.<br/><br/>If the <code>json</code> query parameter is set to
          <code>true</code>, provide the body as a JSON array of events.
          Represent each event as a JSON object, formatted like this: <code>{
          "&lt;parameter 1 name&gt;": &lt;parameter 1 value&gt;, "&lt;parameter
          2 name&gt;": &lt;parameter 2 value&gt;, etc. }</code>.<br/><br/>In all
          cases, the body contains the following
          parameters:<br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>visitorCode</td><td>string</td><td>Required
          if you don't provide it in URL query parameters. Otherwise, Kameleoon
          ignores it.</td><td>Unique Kameleoon visitor ID.<br/>Limit to 100
          characters</td></tr><tr><td>nonce</td><td>string</td><td>Required</td><td>A
          random string of 16 hexadecimal characters, <b>unique to each
          event</b>.</td></tr><tr><td>eventType</td><td>string</td><td>Required</td><td>One
          of the following: <code>STATICDATA</code>, <code>PAGE</code>,
          <code>CONVERSION</code>, <code>TARGETINGSEGMENT</code>,
          <code>EXPERIMENT</code>, <code>PERSONALIZATION</code>,
          <code>WEATHER</code>, <code>CUSTOMDATA</code>, <code>PRODUCT</code>,
          <code>GEOLOCATION</code></td></tr></table><br/><br/><b>List of
          parameters for the eventType
          <code>STATICDATA</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>visitNumber</td><td>int32</td><td>Optional</td><td>Number
          of
          visits</td></tr><tr><td>timeSincePreviousVisit</td><td>int64</td><td>Optional</td><td>Time
          since last visit in
          milliseconds</td></tr><tr><td>browser</td><td>string</td><td>Optional</td><td>Browser's
          name (for example, "Safari").<br/>Limit to 100
          characters</td></tr><tr><td>browserIndex</td><td>int32</td><td>Optional</td><td>Configured
          browser
          index</td></tr><tr><td>browserVersion</td><td>float64</td><td>Optional</td><td>Browser
          version</td></tr><tr><td>os</td><td>string</td><td>Optional</td><td>OS
          name (for example, "Windows").<br/>Limit to 100
          characters</td></tr><tr><td>osIndex</td><td>int32</td><td>Optional</td><td>Configured
          OS
          index</td></tr><tr><td>screenWidth</td><td>int32</td><td>Optional</td><td>Screen
          width</td></tr><tr><td>screenHeight</td><td>int32</td><td>Optional</td><td>Screen
          height</td></tr><tr><td>localeLanguageTag</td><td>string</td><td>Optional</td><td>Local
          language tag (for example,
          "fr").</td></tr><tr><td>deviceType</td><td>string</td><td>Optional</td><td>One
          of the following: <code>DESKTOP</code>, <code>TABLET</code>,
          <code>PHONE</code></td></tr></table><br/><br/><b>List of parameters
          for the eventType
          <code>PAGE</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>href</td><td>string</td><td>Required</td><td>Complete
          URL<br/>Limit to 2048
          characters</td></tr><tr><td>canonicalHref</td><td>string</td><td>Optional</td><td>Canonical
          URL<br/>Limit to 2048
          characters</td></tr><tr><td>title</td><td>string</td><td>Optional</td><td>Page
          title<br/>Limit to 256
          characters</td></tr><tr><td>keyPageIndices</td><td>JSON
          array</td><td>Optional</td><td>A JSON array of configured key page
          indices.</td></tr><tr><td>referrerHref</td><td>string</td><td>Optional</td><td>Complete
          URL of the referrer.</td></tr><tr><td>referrerIndices</td><td>JSON
          array</td><td>Optional</td><td>A JSON array of configured referrer
          indices.</td></tr></table><br/><br/><b>List of parameters for the
          eventType
          <code>CONVERSION</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>goalId</td><td>int64</td><td>Required</td><td>ID
          of the
          goal</td></tr><tr><td>revenue</td><td>float64</td><td>Optional</td><td>Revenue
          generated in the
          goal</td></tr><tr><td>negative</td><td>Boolean</td><td>Optional,<br/>default
          <code>false</code></td><td>Should conversion be
          removed?</td></tr><tr><td>metadata</td><td>JSON
          object</td><td>Optional</td><td>JSON object with the following
          structure: key = metadata id (int32), value = metadata values (JSON
          array of string)<br/>No more than 256 ids<br/>No more than 256 values
          for each id<br/>Every value is limited to 2048
          characters</td></tr></table><br/><br/><b>List of parameters for the
          eventType
          <code>TARGETINGSEGMENT</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>id</td><td>int64</td><td>Required</td><td>Segment
          id</td></tr></table><br/><br/><b>List of parameters for the eventType
          <code>EXPERIMENT</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>id</td><td>int64</td><td>Required</td><td>Experiment
          id</td></tr><tr><td>variationId</td><td>int64</td><td>Required</td><td>Variation
          id. 0 if reference</td></tr></table><br/><br/><b>List of parameters
          for the eventType
          <code>PERSONALIZATION</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>id</td><td>int64</td><td>Required</td><td>Personalization
          id</td></tr><tr><td>variationId</td><td>int64</td><td>Required</td><td>Variation
          id. 0 if
          reference</td></tr><tr><td>unexpositionCause</td><td>string</td><td>Optional</td><td>Only
          valid if variationId is 0. One of the following:
          <code>GLOBAL_EXCLUSION</code>, <code>PERSONALIZATION_CAPPING</code>,
          <code>SCHEDULE</code>, <code>PERSONALIZATION_EXCLUSION</code>,
          <code>VISITOR_CAPPING</code>, <code>SCENARIO</code>,
          <code>PRIORITY</code></td></tr></table><br/><br/><b>List of parameters
          for the eventType
          <code>WEATHER</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>temperature</td><td>float64</td><td>Required</td><td>Temperature
          in
          Kelvin</td></tr><tr><td>humidity</td><td>float64</td><td>Required</td><td>Humidity
          percentage</td></tr><tr><td>pressure</td><td>float64</td><td>Required</td><td>Atmospheric
          pressure in
          hPa</td></tr><tr><td>windSpeed</td><td>float64</td><td>Required</td><td>Wind
          speed in
          meters/second</td></tr><tr><td>cloudiness</td><td>float64</td><td>Required</td><td>Cloudiness
          in
          percentage</td></tr><tr><td>sunriseTime</td><td>int64</td><td>Required</td><td>Sunrise
          time as a UNIX millisecond
          timestamp</td></tr><tr><td>sunsetTime</td><td>int64</td><td>Required</td><td>Sunset
          time as a UNIX millisecond
          timestamp</td></tr><tr><td>weatherCode</td><td>string</td><td>Optional</td><td>Weather
          description (for example, "Sky is Clear").<br/>Limit to 100
          characters</td></tr></table><br/><br/><b>List of parameters for the
          eventType
          <code>CUSTOMDATA</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>index</td><td>int32</td><td>Required</td><td>Configured
          custom data
          index</td></tr><tr><td>mappingIdentifier</td><td>Boolean</td><td>Optional,<br/>default
          <code>false</code></td><td>Is this custom data used as a mapping
          identifier?</td></tr><tr><td>valuesCountMap</td><td>JSON
          object</td><td>Required</td><td>JSON object with the following
          structure: key = value (string), value = count (int32)<br/>No more
          than 256 values<br/>Every value is limited to 2048 characters if
          <code>mappingIdentifier</code> is <code>false</code>, 100
          otherwise</td></tr><tr><td>overwrite</td><td>Boolean</td><td>Optional,<br/>default
          <code>true</code></td><td>Overwrite previous values counts (or
          merge)?</td></tr></table><br/><br/><b>List of parameters for the
          eventType
          <code>PRODUCT</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>ean</td><td>string</td><td>Required</td><td>Product
          code<br/>Limit to 100 characters</td></tr></table><br/><br/><b>List of
          parameters for the eventType
          <code>GEOLOCATION</code>:</b><br/><table><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr><tr><td>country</td><td>string</td><td>Optional</td><td>Country<br/>Limit
          to 100
          characters</td></tr><tr><td>region</td><td>string</td><td>Optional</td><td>Region<br/>Limit
          to 100
          characters</td></tr><tr><td>city</td><td>string</td><td>Optional</td><td>City<br/>Limit
          to 100
          characters</td></tr><tr><td>postalCode</td><td>string</td><td>Optional</td><td>Postal
          code<br/>Limit to 100
          characters</td></tr><tr><td>latitude</td><td>float64</td><td>Optional</td><td>Latitude</td></tr><tr><td>longitude</td><td>float64</td><td>Optional</td><td>Longitude</td></tr></table><br/><br/><b>Note:
          In these examples, Kameleoon assumes you provide the
          <code>visitorCode</code> parameter in the URL query
          part.</b><br/><br/><b>Body example if the URL query parameter
          <code>json</code> is missing or its value is
          <code>false</code>:</b><br/><pre><code>nonce=d2ce4d22083348fb&amp;eventType=STATICDATA&amp;browser=Safari&amp;browserVersion=16.3&amp;deviceType=DESKTOP&amp;os=Windows

          nonce=b0a4253d8acd01c7&amp;eventType=PAGE&amp;href=https%3A%2F%2Fwww.supersite.com%2Fsuperpage%3Fsuperparam%3Dtrue

          nonce=4ca34741a6cc8a48&amp;eventType=CONVERSION&amp;goalId=2&amp;revenue=24.99</code></pre><br/><b>Body
          example if the URL query parameter <code>json</code> is
          <code>true</code> (pretty representation):</b><br/><pre>


          ```

          [
            {
              "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"
            }
          ]


          ```

          </code></pre>
        content:
          '*/*':
            schema:
              type: string
              format: UTF-8
        required: true
      responses:
        '202':
          description: >-
            Kameleoon processed the URL query and accepted the request. The
            response returns no content. <br/> <b>Kameleoon processes the body
            asynchronously and has not checked the body syntax yet.</b>
        '400':
          description: Malformed URL query syntax.
        '401':
          description: >-
            Authentication failed. Either the HTTP header value is malformed, or
            the token is missing or invalid (malformed, expired, or invalid
            signature).
        '403':
          description: Access denied. Forbidden user-agent or restricted resource.
        '413':
          description: The body is too large.
        '429':
          description: Kameleoon rate-limited the request.
        '500':
          description: An unexpected internal error occurred.

````