Track Custom Events
Reteno SDK provides ability to track custom events.
import { logEvent } from "reteno-react-native-sdk";
const eventName = "EVENT_NAME";
const date = new Date().toISOString();
const parameters = [
{
name: "Additional parameter",
value: "Additional value",
},
];
const forcePush = false;
logEvent(eventName, date, parameters, forcePush);The parameters list item structure:
type CustomEventParameter = {
name: string;
value?: string;
};
NoteSet up event-based segmentation to ensure custom events and their parameters are recorded in contact cards, enabling the creation of dynamic segments.
NotedateDate should be in ISO8601 format
forcePushisiOS-only feature; Please read more about it here
Force Push Data
Reteno SDK caches all events (events, device data, user information, user behavior, screen tracking, push statuses, etc) locally into database. Call forcePushData function to send all accumulated events, you can read more about how Reteno caches and sends events here:
function forcePushData(): Promise<void>;Log Screen View Events
You can send screen view events using logScreenView function:
function logScreenView(screenName: string): Promise<void>;There are a few ways to implement the navigation within React Native apps, therefore there is no "one fits all" , this function provides a basic mechanism for sending screen view events, and you can use it whatever way you want.
const someRouteName = getSomeRouteName();
await logScreenView(someRouteName);You can check an example provided by React Navigation library, which can give you an idea of the implementation. See Screen tracking for analytics documentation.
Mobile Push Subscribers
iOS usage
Reteno SDK uses the pushSubscribed parameter for tracking the status of the user’s subscription to push notifications. This covers the following cases:
- When a customer does not subscribe to receive push notifications (
pushSubscribedis false), no token is created for that customer. - When a customer subscribes to receive push notifications (
pushSubscribedis true), a token is created for a new customer. - When a customer unsubscribes from receiving push notifications (
pushSubscribedis false), the existing customer token is deleted.
Reteno can track push notification subscription events. This event will be tracked automatically but it can be managed via lifecycleTrackingOptions in initialize(...).
import { initialize } from "reteno-react-native-sdk";
await initialize({
apiKey: "YOUR_SDK_ACCESS_KEY",
lifecycleTrackingOptions: {
pushSubscriptionEnabled: true,
},
});When push subscription tracking is enabled in lifecycleTrackingOptions, Reteno tracks the following events:
| Event Name | Description |
|---|---|
PushNotificationsSubscribed | This event fires when a customer subscribes for push notifications |
PushNotificationsUnsubscribed | This event fires when a customer unsubscribes from push notifications |
Android usage
Your end-user may prohibit receiving pushes by disabling Reteno notification channel or disabling notifications for your application in Android OS settings menu. In this case SDK will notify its servers to prevent sending push notifications to this specific device.
SDK checks notifications enabled status in these cases:
- On App resume
- On push received event
- On settings changed in Android OS Settings menu (starting from Android 9.0, using system broadcast)
Once status false sent to the server, the backend won't send any push notifications to this device until the end-user re-enables channel/notifications. Once the end-user re-enables channel/notifications the server will be notified and will send push notifications again.
Track Session Events
Reteno can track start and end session events. This is tracked automatically, and can be configured via initialize(...). The configuration applies to both iOS and Android.
import { initialize } from "reteno-react-native-sdk";
await initialize({
apiKey: "YOUR_SDK_ACCESS_KEY",
lifecycleTrackingOptions: {
sessionStartEventsEnabled: true,
sessionEndEventsEnabled: true,
},
});When session tracking is enabled in lifecycleTrackingOptions, Reteno tracks the following events:
| Event Name | Properties | Description |
|---|---|---|
SessionStarted | sessionId, startTime | This event fires when a user's session started |
SessionEnded | sessionID, endTime, durationInSeconds, applicationOpenedCount, applicationBackgroundedCount | This event fires when a user's session ended |
