Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Tracking events

WebEngage offers API for tracking events. This can be done using the /events endpoint as described below.

Any action of interest done by a user is an event. For example, in case of an e-commerce website when a user adds an item to the shopping cart, the website would want to record the "Added to Cart" event along with the product details and price. Events may also be actions carried out by your system in the context of a user, say to track the user's inactivity or to notify departure of a shipment.

Each event has a name and an optional set of attributes describing the event in detail as necessary. An event attribute is a piece of data associated with an event. In the above example, product details and price are the “Added to Cart” event attributes. We recommend you make your events human readable - as an example, you can use a verb in the past tense like “Product Searched” and “Added to Cart”.

Event tracking lets you track user actions on your website, which enables you to create user segments and engagement campaigns based on this activity. We have put together a list of event templates for you to refer to.

System events

WebEngage starts tracking some events automatically as soon as you integrate any of the SDKs. These are called System Events and they track your users’ interactions with your apps, website and campaigns. System events make it easier to analyze user behaviour and optimize your marketing around common business goals such as driving user registrations or purchases. You can use custom events for any other user actions you want to track.

You cannot create system events using WebEngage API.

Using WebEngage API, you should avoid creating events with the same event name as that of system events to avoid confusion.

You can find the list of system events in the introduction section.

Custom events

Custom events enable you to track user actions in your app. /events API only creates custom events.

/events

METHOD
POST

DESCRIPTION
Track custom events.

URL STRUCTURE

https://api.webengage.com/v1/accounts/<YOUR_WEBENGAGE_LICENSE_CODE>/events

HEADERS

Name
Description

x-request-id:{HEX_STRING}

Replace {HEX\_STRING} with a unique random hex string.

If API re-attempts are being made, this tag stops propagation of duplicate events within a 4 hour window. Events with same ID re-attempted within 4 hours won't get duplicated if the previous HTTP request was able to ingest the event.

AUTHENTICATION
User Authentication

EXAMPLE

Run in Postman

curl -X POST https://api.webengage.com/v1/accounts/<YOUR_WEBENGAGE_LICENSE_CODE>/events \
    --header 'Authorization: Bearer <YOUR_API_KEY>' \
    --header 'Content-Type: application/json' \
    --data '{
		"userId": "johndoe",
		"eventName": "Added to Cart",
		"eventTime": "2018-09-15T18:29:00-0800",
		"eventData": {
				"Product ID": 1337,
        "Price": 39.80,
        "Quantity": 1,
        "Product": "Givenchy Pour Homme Cologne",
        "Category": "Fragrance",
        "Currency": "USD"
    }
}'

Make sure you replace YOUR_WEBENGAGE_LICENSE_CODE with your WebEngage license code and YOUR_API_KEY with your WebEngage API key.

PARAMETERS

{
		"userId": "johndoe",
		"eventName": "Added to Cart",
		"eventTime": "2018-09-15T18:29:00-0800",
		"eventData": {
				"Product ID": 1337,
        "Price": 39.80,
        "Quantity": 1,
        "Product": "Givenchy Pour Homme Cologne",
        "Category": "Fragrance",
        "Currency": "USD"
    }
}

Constraints:

  • Event names must be less than 50 characters long.
  • These data types are allowed for event attributes: String, Number, Boolean, Date, JSON Object. JSON Object can contain one of these data types.
  • Event attribute names must be less than 50 characters long. String type attribute values must be less than 1000 characters long.
  • You cannot start your event or event attribute names with we_.
  • You can create at most 25 event attributes of each data type across all instances of an event.
  • If event attribute value is JSON Object, it cannot be used to create user segments. It can only be used to personalize campaigns.
Parameter
Type
Description
Is mandatory

userId

String

Identifier for known user.
Either one of userId or anonymousId is mandatory.
Constraint:

  • userId can be of maximum 100 characters.

No

anonymousId

String

Identifier for anonymous user. Either one of userId or anonymousId is mandatory. In case both IDs are sent, anonymousId will be ignored.

Constraint:

  • anonymousId can be of maximum 100 characters.

No

eventName

String

Name of the event.

Yes

eventTime

String

Date and time when the event occurred in ISO format: yyyy-MM-ddTHH:mm:ss±hhmm.

No

eventData

String

Event attributes as key-value pairs. For example:
{ "Product ID": 1337, "Category": "Fragrance" }
These data types are allowed for custom attributes: String, Number, Boolean, Date, JSON Array, JSON Object. JSON Object can contain one of these data types.

No

1. Event attribute names are case sensitive.
2. eventName must not start with we_. Event names starting with we_ are reserved for WebEngage's internal use, and will be ignored if used for custom events.
3. For custom events, the first datapoint synced to WebEngage defines the data type for that event attribute in WebEngage. Therefore, data types must be consistent with the data that you want to store for the attribute. If you change the data type later, attribute data will stop flowing to WebEngage.

RETURNS

{
	"response": {
		"status": "queued"
	}
}

ERRORS
Example: Both userId and anonymousID missing

{
  "response": {
  "message":"Error: userId and anonymousId cannot be empty.",
  "status":"error"
	}
}

What's Next

On-site feedback

Tracking events