Event

Overview

Event API allows you to track the actions of a user.

Endpoints

Data Center name Event Data Endpoint
Data Center 1 https://api-01.moengage.com/v1/event/
Data Center 2 https://api-02.moengage.com/v1/event/
Data Center 3 (India) https://api-03.moengage.com/v1/event/

For more information about MoEngage data centers, refer to Data Centers in MoEngage.

Syntax

Text
POST https://api-01.moengage.com/v1/event/<APP ID>
POST https://api-02.moengage.com/v1/event/<APP ID>
POST https://api-03.moengage.com/v1/event/<APP ID>
 

Request Body

A sample API request is described:

JSON
{
	"type": "event",
	"customer_id": "john@example.com",
	"device_id": "96bd03b6-defc-4203-83d3-dc1c73080232",
	"actions": [{
			"action": "Added to Cart",
			"attributes": {
				"product": "Mobile",
				"color": "white",
				"Brand": "Apple"
			},
			"platform": "iOS",
			"app_version": "1.2.3",
			"current_time": 1433837969,
			"user_timezone_offset": 19800
		},
		{
			"action": "Purchase",
			"attributes": {
				"product": "MacBook Air",
				"Brand": "Apple"
			},
			"platform": "web",
			"app_version": "1.2.3",
			"current_time": 1433837969,
			"user_timezone_offset": 19800
		}
	]
}

Request Body Fields

Key Datatype Required Description
type String Yes Identify the type of request.
customer_id String Yes Identifier to identify or create a user in MoEngage.
device_id String No device_id in event payload is optional. Default value is customer_id value. The value is used to map event to specific devices.
actions List Yes List of events to be tracked for the user.
action String Yes The name of the event to be tracked.
attributes JSON Object No Dictionary containing event attributes to track with the event.
platform String No Used to identify the platform on which the event happened. Allowed values are ANDROID, iOS, web or unknown.
app_version String No App Version of the app on which the event originated.
user_time Numeric(Epoch time in seconds) or String (ISO 8601 - ) No Local Time at which the event happened.
current_time Numeric (Epoch time in seconds) or String( ISO 8601) No UTC Time at which the event happened
user_timezone_offset Numeric No 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
 

Platform

Ensure that the platform value sent is Android, iOS or web. Platform value depends on the which platform the event was generated.
If you are unsure about the platform on which the event occured, send the value as unknown or do not send any value. Incorrect platform value leads to inconsistencies in platform level campaigns like Push and In-App.

 

Time of the event

MoEngage depends on current_time and user_timezone_offset for generating the local time at which the event occurred. The local time is displayed in the user profile on the dashboard.

user_timezone_offset
Used to determine the local timezone at which the event occurred.
If the field is not present, then either one of the following is used: *The timezone present in user profile is considered. *The event occurred in UTC timezone.
Format contains numeric value between -54000 to 54000. The value is the timezone offset of the local time from UTC in seconds.
current_time
Used to identify the UTC time at which the event occurred.
If the field is not present, then the time at which the request was received is used as the current_time.
Allowed formats for current_time are ISO 8601 , for example 2020-05-31T16:33:35Z or Epoch time in seconds, for example - 1590404615

Examples

The following example provides tracking of numeric, boolean, and date type event attributes.
Use the payload described, where the price is numeric, departure_date is a date type attribute and premium_seat is a boolean attribute.

JSON
{
	"type": "event",
	"customer_id": "john@example.com",
	"actions": [{
			"action": "Flight Bookoed",
			"attributes": {
				"price": 3999,
				"departure_date": "2019-05-21T03:47:35Z",
				"premium_seat": true
			},
			"platform": "iOS",
			"app_version": "1.2.3",
			"current_time": 1433837969,
			"user_timezone_offset": 19800
		}
	]
}

Different attribute types allow you to use the relevant filters while creating segments. For example, when you track the above event, different filters corresponding to the data type of the event attributes are displayed as follows:

2f684d9-Screen_Shot_2020-05-22_at_10.54.15_AM.png

 

Was this article helpful?
0 out of 0 found this helpful