Analytics

The Engagement SDK allows you to hook into our analytic events, making it possible for you to pass through the analytics data to your own provider.

Implementation

The following snippet shows how you can subscribe to analytics events with some common analytics frameworks:

livelikeSdk.analyticService.subscribe(this) { analyticsService ->
        analyticsService?.setEventObserver { eventKey, eventJson ->
        mFirebaseAnalytics.logEvent(eventKey, eventJson)
    }
}

// Only one observer is allowed at a time. 
// To remove the current observer, just pass an empty one:
sdk.analyticService.latest()?.setEventObserver {}
sdk.getAnalyticService().subscribe(this, new Function1<AnalyticsService, Unit>() {
            @Override
            public Unit invoke(AnalyticsService analyticsService) {
                analyticsService.setEventObserver(new Function2<String, JSONObject, Unit>() {
                    @Override
                    public Unit invoke(String eventKey, JSONObject eventJson) {
                        mixpanel.track(eventKey, eventJson);
                        Localytics.tagEvent(eventKey, eventJson);
                        mFirebaseAnalytics.logEvent(eventKey, eventJson);
                        return null;
                    }
                });
            }
        });

🚧

Android SDK 2.48

From SDK 2.48 onwards, the below snippet shows how to hook into our analytic events

sdk.analyticService.setEventObserver { eventkey, jsonObject ->
    mFirebaseAnalytics.logEvent(eventkey, jsonObject)
}
sdk.getAnalyticService().setEventObserver(new Function2<String, JSONObject, Unit>() {
                    @Override
                    public Unit invoke(String eventKey, JSONObject eventJson) {
                    mFirebaseAnalytics.logEvent(eventKey, eventJson);
                     return null;
                    }
                });

The eventKey is the name of the event being fired. The following are the events that we fire. To only register specific events, you can filter down to the ones that you are interested in.

Available Events

The following events with relevant properties are available on Android:

EventDescription
Keyboard SelectedFired every time the user opens the keyboard. Has a "Keyboard Type" property to represent the "Sticker" or "Standard" keyboard.
Chat Message SentFired each time user sends a message.
Chat Message Link ClickedFired each time when user clicks on a link in chat message
Widget Dismissed Fired when a user takes an action to dismiss the widget, such as when user swiping it away. This is event is not fired when a widget expires on its own
Widget Displayed Fired when a user receives a widget. (Note: this is a misnomer because the SDK doesn't have control over whether a widget is actually displayed to users - that is up to your application)
Widget Interacted Fired at the end of widget interaction. Includes a "Number Of Taps" property that counts the number of times a user taps on interactable elements in the widget.
Widget EngagedFired when a vote or answer is submitted on a Widget.
Alert Link OpenedFired when user clicks on a link in Alert Widget.
Video Alert Play StartedFired when video starts playing in Video Alert Widget.
Widget Became InteractiveFired whenever widget becomes interactive for User.

See the Analytics Event Glossary for the full list of available analytics events.

Note : For custom widget events

  1. Widget Became Interactive
    Call the markAsInteractive method available in widget model whenever your Custom Widget UI becomes interactive for the User. Interactive is loosely defined and depends on your specific implementation and use-case. Typically, the Widget is interactive when user is able to submit votes/answers or open links in the case of Alert Widgets. (Available in version 3.0)
// poll widget model for custom poll widget
pollWidgetModel?.markAsInteractive()
pollWidgetModel.markAsInteractive()
  1. Alert Link Opened
    For alert widgets having links, call the alertLinkClicked method available in alert widget model. This will be responsible to trigger the Alert Link Opened event.
// alert widget model for custom alert widget
alertModel.alertLinkClicked(url)
alertModel.alertLinkClicked(url)
  1. Video Alert Play Started
    For video alert widgets having links, call the registerPlayStarted method available in video alert widget model. This will be responsible to trigger the Video Alert Play Started event.
// video alert model for custom video aert widget
videoAlertModel.registerPlayStarted()