Event Tracking

Mobile App Messaging SDK has methods that you can use to track analytical events related to end-user interactions in your app. You can use these events to orchestrate journeys or trigger in-app messages in response to real-time user activity.

Implement Event Tracking 

A tracked event contains the event name and optional event attributes. Your app builds an event object according to your business requirements and then sends it to the MobilePush SDK. When you define these events, make sure that the events implemented in the SDK are identical to the events defined in Marketing Cloud Engagement.

Create the Event 

To create an event in an Android app, use this example.

Android
1val event = EventManager.customEvent("EventName", mapOf("key1" to "value2", "key2" to "value2"))

To create an event in an iOS app, use this example.

iOS
1let event = CustomEvent(name: "EventName", attributes: ["key1": "value1", "key2": "value2"])

Track the Event 

To track an event in an Android app, use this example.

Android
1SFMCSdk.track(event)

To track an event in an iOS app, use this example.

iOS
1SFMCSdk.track(event: event)

Flush Events 

To trigger existing analytics that are queued to be sent, use the flush function.

To flush events in an Android app, use this example.

Android
1SFMCSdk.flush()

To flush events in an iOS app, use this example.

iOS
1SFMCSdk.flush()

Send an Event Immediately 

To send events immediately in an Android app, use this example.

Android
1SFMCSdk.sendImmediate(event)

To send events immediately in an iOS app, use this example.

iOS
1SFMCSdk.sendImmediate(event: event)