> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-partner-guide.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Track Experience Events

> This API tracks impressions (shown) and user interactions (clicked) for accurate experience reporting. To report an impression or click for your experience via API, use the following endpoint.
  




## OpenAPI

````yaml /api/personalize-experience/personalize-experience.yaml post /experiences/events
openapi: 3.0.3
info:
  title: Personalize APIs
  description: >
    Personalize APIs constitute a set of endpoints that can be accessed from
    your platform's code. These APIs offer personalization capabilities and must
    be invoked from your codebase for MoEngage to provide relevant data. After
    receiving the data, you can use it within your platform's code to
    personalize the content for your users.
  version: 1.0.0
servers:
  - url: https://sdk-{dc}.moengage.com/v1
    description: MoEngage API Server
    variables:
      dc:
        default: '01'
        description: >
          The 'X' in the API Endpoint URL refers to the MoEngage Data Center
          (DC). MoEngage hosts each customer in a different DC. You can find
          your DC number (value of X) and replace the value of 'X' in the URL by
          referring to the DC and API endpoint mapping
          [here](https://help.moengage.com/hc/en-us/articles/360057030512-Data-Centers-in-MoEngage).
security:
  - basicAuth: []
tags:
  - name: Experiences
    description: API endpoints for fetching experiences and metadata.
  - name: Events
    description: API endpoints for reporting impressions and clicks.
paths:
  /experiences/events:
    post:
      tags:
        - Events
      summary: Track Experience Events
      description: >
        This API tracks impressions (shown) and user interactions (clicked) for
        accurate experience reporting. To report an impression or click for your
        experience via API, use the following endpoint.
          
      operationId: reportExperienceEvents
      parameters:
        - name: MOE-APPKEY
          in: header
          required: true
          description: >-
            This is the Workspace ID of your MoEngage account that must be
            passed with the request. You can find it in the MoEngage dashboard
            at **Settings** > **Account** > **APIs** > **Workspace ID (earlier
            app id)**.
          schema:
            type: string
            example: Workspace ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                elements:
                  type: array
                  items:
                    type: object
                    properties:
                      customer_id:
                        type: string
                        description: >
                          Your brand provides this field, which should be pasted
                          in the request. Generally, this is the phone number,
                          email ID, or any other unique ID used to uniquely
                          identify the user in MoEngage. This is essential for
                          event mapping back to the user.

                          If the **customer_id** shared is not present in
                          MoEngage, a new user profile will be created with the
                          shared details.
                      user_attributes:
                        type: object
                        description: >
                          This field is used to update the details of a user
                          identified by **customer_id**.

                          If the **customer_id** does not exist, a new user will
                          be created with the details present in
                          **user_attributes**.
                      user_timezone_offset:
                        type: integer
                        description: >
                          The difference in time between UTC and the local
                          system time in a particular time zone. All time zones
                          are defined by their offset from UTC. The offset is
                          expressed as either UTC- or UTC+.

                          **user_timezone_offset** should have a value in
                          seconds, which can be between -54000 to 54000. For
                          example, for IST (UTC+0530), "user_timezone_offset"
                          will be 19800.
                      actions:
                        type: array
                        description: >-
                          Multiple actions or events performed by a user can be
                          grouped together in a single API call
                        items:
                          type: object
                          properties:
                            action:
                              type: string
                              description: >
                                This field identifies the action or the event
                                performed by the user.

                                **Accepted values**

                                *MOE_PERSONALIZATION_MESSAGE_SHOWN*

                                *MOE_PERSONALIZATION_MESSAGE_CLICKED*
                            moe_event_uuid:
                              type: string
                              description: >-
                                Unique identifier to be sent for each event to
                                prevent duplication.
                            event_time:
                              type: string
                              description: >-
                                This field represents UTC time at which the
                                event happened. (Numeric Epoch time in seconds
                                OR String ISO 8601)
                            platform:
                              type: string
                              description: >
                                This field represents the platform on which the
                                user is shown the personalization event. If the
                                values are missing, **Unknown** will be used.

                                **Accepted values**

                                *Android*

                                *IOS*

                                *Web*

                                *TV*
                            attributes:
                              type: object
                              description: >-
                                This field is the experience context sent as
                                part of the response to the Experience Fetch API
                                request call.
                            b_id:
                              type: string
                              description: >
                                This field can be used to uniquely identify
                                click tracking events on multiple elements on a
                                page.

                                For example, *Add to Cart* & *Wishlist* can be
                                used to identify if the user has clicked or
                                tapped on these buttons on the website or the
                                app.
      responses:
        '200':
          description: Success. The event was successfully submitted.
      x-codeSamples:
        - lang: cURL
          label: Impression (Existing User)
          source: >
            curl --location --request POST
            'https://sdk-0X.moengage.com/v1/experiences/events' \

            --header 'Accept: */*' \

            --header 'Content-Type: application/json' \

            --header 'Authorization: Basic <Authorisation>' \

            --header 'MOE-APPKEY: <Your APP Key>' \

            --data-raw '{
                "elements": [
                    {
            "customer_id": "<unique user identifier like email or phone number.
            Eg: john@example.com>",

            "user_timezone_offset": 19800,

            "actions": [
                {
                    "action": "MOE_PERSONALIZATION_MESSAGE_SHOWN",
                    "moe_event_uuid": "aa886712-4537-47c1-b126-2686efda2e26",
                    "event_time": 1725258666,
                    "platform": "web",
                    "attributes": {
            "cid": "66d55ae445921e4d35ae4368_F_T_WP_AB_2_P_0_AU_5A",

            "experience": "Test Server side experience",

            "moe_locale_id": "0",

            "moe_variation_id": "2",

            "audience_name": "All Users",

            "audience_id": "5A",

            "type": "Web Personalization"
                    }
                }
            ]
                    }
                ]
            }'
        - lang: cURL
          label: Impression (New User)
          source: >
            curl --location --request POST
            'https://sdk-0X.moengage.com/v1/experiences/events' \

            --header 'Accept: */*' \

            --header 'Content-Type: application/json' \

            --header 'Authorization: Basic <Authorisation>' \

            --header 'MOE-APPKEY: <Your APP Key>' \

            --data-raw '{
                "elements": [
                    {
            "customer_id": "john@example.com",

            "user_attributes": {
              "name": "John Doe",
              "first_name": "John",
              "last_name": "Doe"
            }

            "user_timezone_offset": 19800,

            "actions": [
                {
                    "action": "MOE_PERSONALIZATION_MESSAGE_SHOWN",
                    "moe_event_uuid": "aa886712-4537-47c1-b126-2686efda2e26",
                    "event_time": 1725258666,
                    "platform": "web",
                    "attributes": {
            "cid": "66d55ae445921e4d35ae4368_F_T_WP_AB_2_P_0_AU_5A",

            "experience": "Test Server side experience",

            "moe_locale_id": "0",

            "moe_variation_id": "2",

            "audience_name": "All Users",

            "audience_id": "5A",

            "type": "Web Personalization"
                    }
                }
            ]
                    }
                ]
            }'
        - lang: cURL
          label: Impression (Anonymous User)
          source: >
            curl --location --request POST
            'https://sdk-0X.moengage.com/v1/experiences/events' \

            --header 'Accept: */*' \

            --header 'Content-Type: application/json' \

            --header 'Authorization: Basic <Authorisation>' \

            --header 'MOE-APPKEY: <Your APP Key>' \

            --data-raw '{
                "elements": [
                    {
            "customer_id": "<identifier for the user for the session>",

            "user_timezone_offset": 19800,

            "actions": [
                {
                    "action": "MOE_PERSONALIZATION_MESSAGE_SHOWN",
                    "moe_event_uuid": "aa886712-4537-47c1-b126-2686efda2e26",
                    "event_time": 1725258666,
                    "platform": "web",
                    "attributes": {
            "cid": "66d55ae445921e4d35ae4368_F_T_WP_AB_2_P_0_AU_5A",

            "experience": "Test Server side experience",

            "moe_locale_id": "0",

            "moe_variation_id": "2",

            "audience_name": "All Users",

            "audience_id": "5A",

            "type": "Web Personalization"
                    }
                }
            ]
                    }
                ]
            }'
        - lang: cURL
          label: Click (Existing User)
          source: >
            curl --location --request POST
            'https://sdk-0X.moengage.com/v1/experiences/events' \

            --header 'Accept: */*' \

            --header 'Content-Type: application/json' \

            --header 'Authorization: Basic <Authorisation>' \

            --header 'MOE-APPKEY: <Your APP Key>' \

            --data-raw '{
                "elements": [
                    {
            "customer_id": "<unique user identifier like email or phone number.
            Eg: john@example.com>",

            "user_timezone_offset": 19800,

            "actions": [
                {
                    "action": "MOE_PERSONALIZATION_MESSAGE_CLICKED",
                    "moe_event_uuid": "aa886712-4537-47c1-b126-2686efda2e26",
                    "event_time": 1725258666,
                    "platform": "web",
                    "attributes": {
            "cid": "66d55ae445921e4d35ae4368_F_T_WP_AB_2_P_0_AU_5A",

            "experience": "Test Server side experience",

            "moe_locale_id": "0",

            "moe_variation_id": "2",

            "b_id": "Add to Cart",

            "audience_name": "All Users",

            "audience_id": "5A",

            "type": "Web Personalization"
                    }
                }
            ]
                    }
                ]
            }'
        - lang: cURL
          label: Click (New User)
          source: >
            curl --location --request POST
            'https://sdk-0X.moengage.com/v1/experiences/events' \

            --header 'Accept: */*' \

            --header 'Content-Type: application/json' \

            --header 'Authorization: Basic <Authorisation>' \

            --header 'MOE-APPKEY: <Your APP Key>' \

            --data-raw '{
                "elements": [
                    {
            "customer_id": "john@example.com",

            "user_attributes": {
              "name": "John Doe",
              "first_name": "John",
              "last_name": "Doe"
            }

            "user_timezone_offset": 19800,

            "actions": [
                {
                    "action": "MOE_PERSONALIZATION_MESSAGE_CLICKED",
                    "moe_event_uuid": "bb997812-4537-47c1-b126-2686efda2e27",
                    "event_time": 1725258670,
                    "platform": "web",
                    "attributes": {
            "cid": "66d55ae445921e4d35ae4368_F_T_WP_AB_2_P_0_AU_5A",

            "experience": "Test Server side experience",

            "moe_locale_id": "0",

            "moe_variation_id": "2",

            "b_id": "Add to Cart",

            "audience_name": "All Users",

            "audience_id": "5A",

            "type": "Web Personalization"
                    }
                }
            ]
                    }
                ]
            }'
        - lang: cURL
          label: Click (Anonymous User)
          source: >
            curl --location --request POST
            'https://sdk-0X.moengage.com/v1/experiences/events' \

            --header 'Accept: */*' \

            --header 'Content-Type: application/json' \

            --header 'Authorization: Basic <Authorisation>' \

            --header 'MOE-APPKEY: <Your APP Key>' \

            --data-raw '{
                "elements": [
                    {
            "customer_id": "<identifier for the user for the session>",

            "user_timezone_offset": 19800,

            "actions": [
                {
                    "action": "MOE_PERSONALIZATION_MESSAGE_CLICKED",
                    "moe_event_uuid": "aa886712-4537-47c1-b126-2686efda2e26",
                    "event_time": 1725258666,
                    "platform": "web",
                    "attributes": {
            "cid": "66d55ae445921e4d35ae4368_F_T_WP_AB_2_P_0_AU_5A",

            "experience": "Test Server side experience",

            "moe_locale_id": "0",

            "moe_variation_id": "2",

            "b_id": "Add to Cart",

            "audience_name": "All Users",

            "audience_id": "5A",

            "type": "Web Personalization"
                    }
                }
            ]
                    }
                ]
            }'
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >
        Authentication is done via Basic Auth. This requires a base64-encoded
        string of your credentials in the format 'username:password'.


        - **Username**: Use your MoEngage workspace ID (also known as the App
        ID). You can find it in the MoEngage dashboard at **Settings** >
        **Account** > **APIs** > **Workspace ID (earlier app id)**.

        - **Password**: Use your API Key, which you can find within the
        **Personalize** tile.


        **Note**: After you generate and save the Personalize API Key (SECRET
        KEY), DO NOT generate a new key unless there is a security breach. After
        you generate a different key and save it, API calls using the older key
        won't work.


        For more information on authentication and getting your credentials,
        refer
        [here](https://www.moengage.com/docs/api/introduction#getting-your-credentials).

````