Skip to main content

Analytics

This guide explains how to integrate and handle analytics events in the LikeMinds Feed using the LikeMinds SDK. By leveraging analytics callbacks, you can track events such as likes, comments, or navigation to specific screens, and forward this data to your preferred analytics platform (e.g., Firebase, Mixpanel).

Refer to Analytics Events to see the list of events that are being tracked.

Steps

Step 1: Create an Analytics Callback

The LMFeedBlocListener class listens to analytics events triggered within the feed. The events can be captured using the LMFeedAnalyticsEventFired model.

To handle events, create the analyticsBlocListener function.

void analyticsBlocListener(BuildContext context, LMFeedAnalyticsState state) {
if (state is LMFeedAnalyticsEventFired) {
// state is of type LMFeedAnalyticsEventFired
// handle the event here
// state variable will have all the data related
// to the event
}
}

Step 2: Wrap the Root Widget with LMFeedBlocListener

To enable the analytics callback, wrap your root widget with the LMFeedBlocListener. This setup ensures that the analyticsBlocListener function is invoked whenever an analytics event is fired.

Here’s how you can wrap the widget:

LMFeedBlocListener(
analyticsListener: analyticsBlocListener,
child: YourRootWidget(),
),

Models

LMFeedAnalyticsEventFired

PropertyTypeDescription
eventNameStringThe name of the event fired.
eventPropertiesMap<String, dynamic>Additional properties of the event (e.g., post ID, likes count).
widgetSourceLMFeedWidgetSource?The source of the widget that triggered the event (e.g., feedroom, post detail).

Conclusion

By following the above steps, you can seamlessly integrate analytics tracking into your LikeMinds Feed implementation. This setup enables you to monitor user interactions effectively and gain insights into feature usage.