Event API

Event API enables you to pass business events to WebEngage for analytics, user segmentation or to trigger engagements or other actions. All passed events are captured in the Event analytics screen on the dashboard.

There is only one method in this API

webengage.track

This method sends en event with some (optional) associated data to WebEngage.

webengage.track(eventName, [eventData]);

Parameters

Name
Type
Description

eventName

String

Name of the event

eventAttributes

Object

Attributes associated with the event (optional).

Event and attribute names starting with we_ are reserved for WebEngage internal purposes and should not be used to name your own events and event attributes

Event attribute values

String, boolean and number attribute values should be passed in the form of Javascript strings, booleans and numbers respectively. Similarly date attribute values are expected in the form of Javascript date objects. Complex and nested data such as maps and lists can also be passed as plain Javascript objects and arrays.

Please take a note of the general restrictions on attribute names and values while tracking events

Examples of a webengage.track call

webengage.track('Added To Cart', {
    /* numbers */
    "Product ID" : 1337,
    "Price"      : 39.80,
    "Quantity"   : 1,

    /* strings */
    "Product"    : 'Givenchy Pour Homme Cologne',
    "Category"   : 'Fragrance',
    "Currency"   : 'USD',

    /* booleans */
    "Discounted" : true
});

webengage.track("Order Placed", {
    "Amount"   : 2300,

    /* dates */
    "Delivery Date" : new Date("2017-01-09T00:00:00.000Z"),

    /* complex nested data */
    "Products" : [
        {
            "SKU Code": "UHUH799",
            "Product Name": "Killer Jeans"
            "Price": 300.49,
            "Details": {
                "Size": "L"
            }
        },
        {
            "SKU Code": "FBHG746",
            "Product Name": "Rockstar Jackets"
            "Price": 507.99,
            "Details": {
                "Size": "L",
                "Returnable": false
            }
        },
    ],

    /* objects or maps */
    "Delivery Address": {
        "City": "Mumbai",
        "PIN": "400010"
    },

    /* arrays */
    "Coupons Applied": [
        "BOGO17",
        "MAXTUE3"
    ]
});

Events