User and Event Tracking
The user and event tracking functionality in the Ionic SDK allows you to track user behavior and build user profiles which then can be used to create segments and target them with personalized communication.
To get started with user tracking and event tracking for Android/iOS platforms, refer here. You must integrate the Ionic base SDK before you begin with user and event tracking integration.
User Tracking
Manage user profiles, identities, and events to understand user behavior and create personalized experiences. To explore how to track user behavior and events with the Smartech Ionic SDK, click below.
- Building User Profile
- Identifying Users
- Login Event
- Clear Identity
- Logout Event
- Install Event Tracking(For Android)
- Custom Event Tracking
- Location Tracking
- GDPR Opt-in and Opt-out
Build User Profile
You can pass additional information associated with a user to Smartech as user attributes. The example below demonstrates how to update the user profile.
const SmartechBaseCordova = window.plugins.SmartechBaseCordova;
const payloadata =
{
FIRST_NAME: "",
LAST_NAME: "",
AGE: "",
COUNTRY: "",
STATE: "",
CITY: "",
PINCODE: ""
};
SmartechBaseCordova.updateUserProfile(payloadata);
Data Types and Format Requirements
- Smartech supports String, Integer, Float, and Date data types.
- Date must be provided in yyyy-mm-dd format.
Identify Users
You can use the below method to set a user’s identity. In case the user’s identity is not available at login, use the method after the identity is available.
SmartechBaseCordova.setUserIdentity("<USER'S_IDENTITY>");
Login Event
You can call the Smartech login method when the user successfully logs into the app and also set the user’s identity before calling the SDK's login method.
SmartechBaseCordova.login("<USER'S_IDENTITY>");
Clear Identity
You can clear the user's identity to track all activity anonymously.
SmartechBaseCordova.clearUserIdentity();
Logout Event
You should call the Smartech logout method after the user logs out from the application. If you want to clear the user identity, pass true
as the parameter. By logging out with the user identity cleared, you avoid receiving any personalized push notifications.
SmartechBaseCordova.logoutAndClearUserIdentity(false);
Custom Event Tracking
You can utilize this method to monitor custom events defined by you. This allow analysis of user's product usage patterns. Each event must have a name and a collection of attributes with detailed insights into the event.
SmartechBaseCordova.trackEvent("EVENT_NAME", "PAYLOAD_STRING");
// Sample code for reference purpose only
const payloadata = {
name: "Galaxy",
description: "20gram bars",
payload_id: "1",
event_id:21
};
SmartechBaseCordova.trackEvent("Page Browse", payloadata);
Location Tracking
You can track user's location or set it yourself.
SmartechBaseCordova.setUserLocation(LATITUDE_DOUBLE_VALUE, LONGITUDE_DOUBLE_VALUE);
// Sample code for reference purpose only
SmartechBaseCordova.setUserLocation(19.0760, 72.8777);
GDPR Opt-in and Opt-out
Opt for Tracking
You opt-out of tracking by calling the optTracking()
method with a false
value. Once you opt-out of tracking, you need to explicitly opt-in. Until you opt-in, no communication occurs with the panel. To opt-in for tracking, call the optTracking()
method with a true
value.
var booleanOpt = false/true;
SmartechBaseCordova.optTracking(booleanOpt);
//To check the current consent status for tracking, call the following method
SmartechBaseCordova.hasOptedTracking(function(status) {
});
Opt For Push Notifications
You can use the optPushNotification()
method to choose whether to opt-in or opt-out of Push notifications sent from the panel. Passing false
in the parameter opt you out of Push notifications. To opt in, pass true
in the parameter.
var booleanOpt = false/true
SmartechPushCordova.optPushNotification(booleanOpt)
//To check the current consent status for push notification, call the following method
SmartechPushCordova.hasOptedPushNotification(function(status) {
})
Opt For In-App Messages
You can use the optInAppMessage()
method to choose whether to opt-in or opt-out of In-app messages sent from the panel. Passing false
in the parameter opt you out of In-app messages. To opt in, pass true
in the parameter.
var booleanOpt = false/true
SmartechBaseCordova.optInAppMessage(booleanOpt)
//To check the current consent status for In-App Message, call the following method
SmartechBaseCordova.hasOptedInAppMessage(function(status) {
})
Updated 5 months ago