Tracking Events
Record users action via event API.
Before moving onto Tracking Events, it will be most helpful to get a better grasp of System & Custom events and their respective attributes. It will help you to understand the workings of Tracking Events much better. Click here to view Custom Event Templates to get a good understanding.
NotifyVisitors immediately begins tracking once you integrate the SDK. These are referred to as System Events, and they start tracking common user interactions with your app and also your campaigns. Click here to view the System Events that we automatically track for you.
You can create your Custom Events that will track your user interactions, important to your business growth. You can further break down each Custom Event into more Event Attributes as:
- Quantity
- Price
- Category
Granular data like this will enable you to engage more users through personalized and contextual campaigns through Omni-channels or all channels of engagement.
Important
What you see as 'Platform' in the Custom Events of your NotifyVisitors dashboard is the sdk_id and signifies SDK type.
sdk_id 1 = Web
sdk_id 2 = Android
sdk_id 3 = iOS
Tracking Custom Events for Android
Events API records all the actions that the users perform. It also records any property associated with them.
These are used for:
● Analytics
● User segmentation
● To trigger engagements or other actions
All API events are part of the NotifyVisitors Analytics object of Android SDK. To get an instance of
NotifyVisitors Analytics object, find the code below:
NotifyVisitorsApi.getInstance(activityContext).event(String eventName, JSONObject attributes, String ltv, String scope);
NotifyVisitorsApi.getInstance(activityContext).event(String eventName, JSONObject attributes, String ltv, String scope)
EVENT_NAME (String)
USAGE: Specify name to the event you want to track.
- It is a string value.
- Use only Alpha Numerics.
- You can use white spaces or special characters.
- You can use underscore ‘_’.
EVENT_ATTRIBUTES (JSONObject)
USAGE: These attributes are associated with Users' Event
Attribute values are passed in the form of Javascript:
- Strings
- Booleans
- Numbers
- Date Attribute values are written using Javascript date objects
Attribute Name should contain only:
- Alpha-numerics
- No spaces
- Only underscore _
- Name within " "
- No special characters
- Attribute ends with ;
LIFETIME_VALUE (Integer)
USAGE: For awarding a score point to the user like- 10 or 100
SCOPE (Integer)
Usage: The scope of the event defines, whether the event should be tracked every time it occurs, or per session, or once in a lifetime. This parameter is used to minimize the duplication of data in analytics.
It is an integer whose values are as follows :
- Track every time the api is called.
- Track once per session.
- Track once in a lifetime.
Example for Tracking Events
NotifyVisitorsApi.getInstance(activityContext).event("subscribed", null, "7","2");
NotifyVisitorsApi.getInstance(activityContext).event("subscribed", null, "7", "2")
Tracking Event Attributes
After NotifyVisitors has been initialized successfully, you can track a Custom Event in the following manner:
JSONObject eventAttributes = new JSONObject();
try {
eventAttributes.put("name","john");
eventAttributes.put("number","98987XXXXX");
eventAttributes.put("user_score","340");
eventAttributes.put("plan_type",3);
} catch (JSONException e) {
e.printStackTrace();
}
NotifyVisitorsApi.getInstance(activityContext).event("subscribed", eventAttributes, "7","2");
val eventAttributes = JSONObject()
try {
eventAttributes.put("name", "john")
eventAttributes.put("number", "98987XXXXX")
eventAttributes.put("user_score", "340")
eventAttributes.put("plan_type", 3)
} catch (e: JSONException) {
e.printStackTrace()
}
NotifyVisitorsApi.getInstance(activityContext).event("subscribed", eventAttributes, "7", "2")
How to Track Complex Event Attributes
- You can pass complex event attributes with NotifyVisitors as List and Map data types.
- You cannot create segments.
- You can use this data for personalizing your campaigns in the following manner:
try {
JSONObject address = new JSONObject();
address.put("Flat", "h-3/94");
address.put("Building Number", "B2");
address.put("Locality", "Bengali Road");
address.put("City", "Palam");
address.put("State", "Delhi");
address.put("PIN", "110045");
JSONObject eventAtrributes = new JSONObject();
eventAtrributes.put("name","john");
eventAtrributes.put("number","98987XXXXX");
eventAtrributes.put("user_score","340");
eventAtrributes.put("plan_type",3);
eventAtrributes.put("Address", address);
NotifyVisitorsApi.getInstance(activityContext).event("subscribed", eventAtrributes, "7","2");
} catch (JSONException e) {
e.printStackTrace();
}
try {
val address = JSONObject()
address.put("Flat", "h-3/94")
address.put("Building Number", "B2")
address.put("Locality", "Bengali Road")
address.put("City", "Palam")
address.put("State", "Delhi")
address.put("PIN", "110045")
val eventAtrributes = JSONObject()
eventAtrributes.put("name", "john")
eventAtrributes.put("number", "98987XXXXX")
eventAtrributes.put("user_score", "340")
eventAtrributes.put("plan_type", 3)
eventAtrributes.put("Address", address)
NotifyVisitorsApi.getInstance(activityContext).event("subscribed", eventAtrributes, "7", "2")
} catch (e: JSONException) {
e.printStackTrace()
}
Event Response Callback
You can get event trigger response in the form of JSONObject. It will help you to track whether it is successful or not.
NotifyVisitorsApi.getInstance(activityContext).getEventResponse(new OnEventTrackListener() {
@Override
public void onResponse(JSONObject jsonObject) {
//do your task
}
});
NotifyVisitorsApi.getInstance(this).getEventResponse(object : OnEventTrackListener{
override fun onResponse(data: JSONObject?) {
//do your task here
}
})
This callback will provide you with a response in the following format-
{
"status":"success",
"eventName":"app_launch",
"message":"Tracking Conversion successful for app_launch.",
"type":0,
"callbackType":"event"
}
In the above output, eventName will be the same as that you pass in the app. The other parameters will return the values corresponding to the scenario or problem that occurred when the event was triggered. So, below are the different values that you can receive in the callback:
STATUS
|
MESSAGE
|
TYPE
|
CALLBACK TYPE
|
Success
|
Tracking Conversion successful for <event_name> |
0 |
Event
|
Fail
|
Please check for Event Name, it shouldn't be NULL or EMPTY. |
1 | |
Context not found. |
2.0, 2.1, 2.2 | ||
Invalid SCOPE value found. |
3.0, 3.1, 3.2 | ||
<event_name> event can be tracked once in <scope> days.
It will get tracked after <remaining_days> days. |
4.0, 4.1 | ||
<event_name> event can be tracked once in <scope> days.
It will get tracked from tomorrow or later. |
5 | ||
Analytics / Event Status is inactive in the NV Panel. | 6.0, 6.1, 6.2 | ||
Wrong credentials found.
Recheck the NotifyVisitors BrandID and Encryption Key in your app's manifest file. |
7 | ||
Something went wrong while processing via the API. | 8 | ||
No response available corresponding to this event. | 9.0, 9.1 | ||
LIFE-CYCLE Events INACTIVE or Your account is not upgraded. Kindly activate LIFE-CYCLE Event within your NotifyVisitors account or upgrade your account if required. | 10 | ||
Conversion failed. | 11.0, 11.1 | ||
Authentication error. | 12.0, 12.1 | ||
Something went wrong while processing the response. | 13 | ||
No internet found. | 16.0, 16.1 | ||
Attribution tracking is disabled in the NV Panel. | 17.0 |
Guidelines
- Names and Custom Event Attribute names will be case sensitive and must be under 50 characters in length.
- Keep the String attribute values under 1000 characters in length.
- Custom Event Attributes are of data types like:
- String
- Boolean
- all subclasses of Number
- Date
- Map
- List
- Event Attributes for a Custom Event cannot exceed 25 times per data type.
- You cannot create segments for an Event Attribute value that is a List or a Map. However, you can use it in personalized campaigns.
- The first data point declared gets synced with NotifyVisitors. It will define the data type for the event attribute.
- The data type must be consistent with the value that you store against the attribute. Do not change the data type at a later stage because it will no longer flow to your NotifyVisitors dashboard.
Feel free to contact us at [email protected] if you need further help. We're only an email away!
Updated 9 months ago