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

# Report Experience Events

> With Server-side personalization, the experience is personalized on the server. You can use either the Report Impression API or the MoEngage Web SDK to report impressions.

**Applicable for all platforms, including website, mobile or TV app & more.**

To report an impression for your campaign, use the API endpoint given below.

The API Request to report clicks using APIs remains the same as the one to report impressions. The only change is to the value of the **action** field to **MOE_PERSONALIZATION_MESSAGE_CLICKED**.


### Using MoEngage Web SDK

Refer to [this](https://developers.moengage.com/hc/en-us/articles/39084350090772-Personalize-API-Experience-events-tracking#h_01JXWHX5488QT9XMEN0R5WPX6P) article on reporting Experience shown event using the Personalize SDK.

### Using MoEngage App SDK

* Refer to [this](https://developers.moengage.com/hc/en-us/articles/38474488247444-Personalize-Experience-Events-Tracking#h_01JXWHX5488QT9XMEN0R5WPX6P) article on reporting Experience shown event using the **Android** SDK.
* Refer to [this](https://developers.moengage.com/hc/en-us/articles/38532362954004-Personalize-Experience-Events-tracking#h_01JY0XF2DW9VKRF3S7G5FNR4XR) article on reporting Experience shown event using the **iOS** SDK.


## OpenAPI

````yaml /api/personalize-experience/personalize-experience.yaml post /experiences/events
openapi: 3.0.3
info:
  title: Personalize APIs
  description: >
    <span style="background-color: #ffffff; color: #374151;"><span
    style="-webkit-text-stroke-width: 0px; display: inline !important; float:
    none; font-family: Söhne, sans-serif; font-size: 16px; font-style: normal;
    font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400;
    letter-spacing: normal; orphans: 2; text-align: start;
    text-decoration-color: initial; text-decoration-style: initial;
    text-decoration-thickness: initial; text-indent: 0px; text-transform: none;
    white-space: pre-wrap; widows: 2; word-spacing: 0px;">Personalize APIs
    constitute a set of endpoints that can be accessed from your platform's
    code. </span></span>

    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 the same 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).
        enum:
          - '01'
          - '02'
          - '03'
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: Report Experience Events
      description: >
        With Server-side personalization, the experience is personalized on the
        server. You can use either the Report Impression API or the MoEngage Web
        SDK to report impressions.


        **Applicable for all platforms, including website, mobile or TV app &
        more.**


        To report an impression for your campaign, use the API endpoint given
        below.


        The API Request to report clicks using APIs remains the same as the one
        to report impressions. The only change is to the value of the **action**
        field to **MOE_PERSONALIZATION_MESSAGE_CLICKED**.
      operationId: reportExperienceEvents
      parameters:
        - name: MOE-APPKEY
          in: header
          required: true
          description: >-
            This is the Workspace ID of your MoEngage account, and it needs to
            be passed along with the request. You can find your MoEngage
            Workspace ID in the MoEngage Dashboard API Settings. For more
            information, refer to Authentication.
          schema:
            type: string
            example: Workspace ID
        - name: Authorization
          in: header
          required: true
          description: >-
            This authentication parameter, used for access control, must be
            passed along with the request. To generate the authentication
            header, refer to Authentication.
          schema:
            type: string
            example: Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U==
      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: >
        The API request will be authenticated through Basic Authentication.
        Basic Authentication sends a Base64-encoded string containing your
        username and password with every API request. It encodes a
        'username:password' string in Base64 and appends the encoded string with
        'Basic '. This string is included in the authorization header as shown
        below:


        `{"Authorization":"Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}`


        The username and password details can be obtained from the MoEngage
        Dashboard.

        1. Navigate to **Settings** -> **Account** -> **APIs.**

        2. Click **the Copy** icon in the **Personalize** tile in the **API
        Key**s section to copy the API Key.

        3. Use the **Workspace ID** as the username and the Personalize API Key
        as the password to generate the authentication header.

````