Send and Track Events

This document will cover the method to send event to Suprsend platform

In this section, we'll cover how to send events to the Suprsend platform for both iOS and Android application

Pre-requisites

  1. Integrate Android SDK
  2. Create User Profile
  3. Create Template on SuprSend platform - if you want to trigger workflow by passing the event
  4. Create Workflow on SuprSend Platform - if you want to trigger workflow by passing the event

Create Workflow on SuprSend Platform

For Event based workflow trigger, you'll have to create the workflow on SuprSend Platform.

577

Sending Events to SuprSend

Once the workflow is configured, you can pass the Event Name ( GROCERY_PURCHASED in above example) defined in workflow configuration from your SDK and the related workflow will be triggered. Variables added in the template should be passed as event properties

You can send Events from your app to SuprSend platform by using ssApi.track() method

//method
ssApi.track(eventName: String) //for single event
ssApi.track(eventName: String, properties: JSONObject) //for event with multiple properties

//Sample values 
ssApi.track(eventName = "Home Screen Viewed") //for single event

//for event with multiple properties
ssApi.track(
            eventName = "product_viewed",
            properties = JSONObject().apply {
              put("product_id", "P1")
              put("product_name", "Car")
              put("amount", 10000)
            }
        )

❗️

Naming Guideline

When you create an Event or a property, please ensure that the Event Name or Property Name does not start with $ or ss_, as we have reserved these symbols for our internal events and property names.


System Events tracked by SuprSend

There are some system events tracked by SuprSend SDK by default. These are some basic events, as well as events that are necessary for tracking notifications related activity (like delivered, clicked, etc).
You are not required to do anything here.

Event NameDescription
$app_installed$app_installed will get tracked when user launch his app for the first time.

FYI cases in which it will also get called

1. When user lanches his app for first time.
2. When user uninstall the app and installs it again.
3. [Multiple device login ]When user launch app for first time on different devices.
4. When user clears the app cache and relaunches the app.
$app_launchedGets tracked when user launches the app each time.
$user_loginGets tracked when user logs in inside the app
$user_logoutGets tracked when user logs in to the app
$notification_deliveredWill get tracked when the suprsend notification payload is received at sdk end.
$notification_clickedWill get tracked when user either clicks the notification body or any action button in the notification.
$notification_dismissedWill get tracked when user dismisses the notification by left swiping the notification or by clicking on "Clear All" button

Advanced Concepts

1. Super Properties

Super properties are data that are always sent with events data. These super properties will be sent in each event after calling this method. Super properties will be stored in local storage, and will persist across invocations of app.

Set Super Property

There are some super properties that SuprSend SDK will send by default. Developer can set custom super properties as well with ssApi.getUser().setSuperProperty() method

//method

//for setting single super property
ssApi.getUser().setSuperProperty(key: String, value: Any)
//for setting multiple super properties
ssApi.getUser().setSuperProperties(jsonObject: JSONObject) 


//Example

//for setting single super property
ssApi.getUser().setSuperProperty("Location", "Banglore")
//for setting multiple super properties
ssApi.getUser().setSuperProperties(JSONObject().apply {
    put("Location","XYZ")
    put("Pincode", 1234567)
    put("Amount", 99.99")
})

Default Super properties tracked by SuprSend SDK:

Super PropertyDescriptionSample Value
$app_version_stringVersion of your app0.0.1
$app_build_numberBuild number of your app2
$osOperating system of the userandroid
$manufacturerManufacturer of the user's deviceOnePlus
$brandBrand of the user's deviceOnePlus
$modelModel of the user's deviceGM1901
$deviceIdDevice id89eead05a0150146
$ss_sdk_versionSuprSend SDK version0.1.31
$networkNetwork on which the user iswifi
$connectedWhether the user is connected to the networktrue

Unset Super Property

There are unset custom super properties with ssApi.getUser().unSetSuperProperty() method. This method will stop calling that property with every event trigger.

//method
ssApi.getUser().unSetSuperProperty(key: String) 

//Example
ssApi.getUser().unSetSuperProperty(listOf("Location","Pincode","Amount"))


2. Special Events

Special events are some best use case events defined by SuprSend. You could call these events with some of their pre-defined properties.

1. Purchase Made

You can call purchase made event if user is doing a transaction on your platform. You can pass property values like product id, product name, and amount in the event.

ssApi.purchaseMade(properties: JSONObject)
ssApi.purchaseMade(JSONObject().apply {
            put("product_id", "P1")
            put("product_name", "Car")
            put("amount", "$15000")
        })

3. Flush Events

SuprSend SDK automatically flushes events at an interval of 5 seconds, and on certain activities like app relaunch, etc.
If you wish to flush a time sensitive event to SuprSend immediately, you can use the suprSendApi.flush() method.

All the system tracked events are flushed immediately

suprSendApi.flush();