Skip to main content

Analytics

Give Octopus analytics more context about your users, and observe the events the SDK emits while they use the community.

Before you begin​

  • Complete the Quickstart: the SDK is initialized.
  • To forward the events of the SDK, have your own analytics tool set up in your app.
  • To report the cohort of your own A/B test, see A/B testing.

How it works​

Analytics flows in two directions:

Custom eventsEvents of the SDK
DirectionYour app → Octopus analyticsThe SDK → your app
What it carriesEvents you define, with a free-form name and string propertiesWhat the user does in the Octopus UI: posts, reactions, screens, sessions…
Where it goesOctopus analyticsYour code only: the SDK sends these events nowhere. You decide whether to forward them to your analytics tool.
ReferenceStep 1Step 2 and the events reference

You are responsible for what you send and forward:

  • Never send sensitive data (health, religion, political opinions, sexual orientation, biometric or genetic data, criminal records), payment details, government ids, login credentials, or the content of private messages.
  • Where privacy laws apply to your users (GDPR in the EEA and the UK, CCPA in California, LGPD in Brazil…), collect the consent they require before you send or forward analytics.

1. Send custom events​

Define your own event types: there is no fixed catalog. Each event has a name and any properties you want to attach, and every property value is a string. Send as many types as your app needs, for example Purchase, SignUp, TutorialCompleted or AddToCart.

  • event: TrackerEvent.Custom — the event, with its name and its properties: Map<String, TrackerEvent.Custom.Property>.
  • The function is suspend: call it from a coroutine.
scope.launch {
OctopusSDK.track(
event = TrackerEvent.Custom(
name = "Purchase",
properties = mapOf(
"price" to TrackerEvent.Custom.Property(value = "1.99"),
"currency" to TrackerEvent.Custom.Property(value = "EUR"),
"product_id" to TrackerEvent.Custom.Property(value = "product1"),
)
)
)

// A different event type: send as many as you need
OctopusSDK.track(
event = TrackerEvent.Custom(
name = "TutorialCompleted",
properties = mapOf("level" to TrackerEvent.Custom.Property(value = "3"))
)
)
}

2. Listen to the events of the SDK​

Android availableiOS availableFlutter availableReact Native availableUnity ≥ 1.12.2

What the user does inside the Octopus UI is otherwise invisible to your app. Subscribe to the events of the SDK to feed your own analytics tool with them. Every event and its fields are listed in the events reference.

  • OctopusSDK.events: Flow<OctopusEvent> — emits every event of the SDK.
// Convert Octopus events into events of your analytics tool,
// here Firebase Analytics
scope.launch {
OctopusSDK.events.collect { event ->
when (event) {
is OctopusEvent.PostCreated -> {
FirebaseAnalytics.getInstance(context).logEvent(
"post_created",
Bundle().apply {
putString("group", event.groupId)
putInt("text_length", event.textLength)
putBoolean("has_poll", OctopusEvent.PostCreated.Content.POLL in event.content)
putBoolean("has_image", OctopusEvent.PostCreated.Content.IMAGE in event.content)
}
)
}
else -> Unit // Handle the other events
}
}
}
warning

collect never returns: launch it in a scope that lives as long as you need the events, for example an application-wide scope.


See it in the samples​

Behavior and limits​

  • To have a new custom event type included in your reports, contact Octopus first so it can be set up.
  • The events of the SDK only cover what the user does in the Octopus UI, and they are emitted in your app only.
  • Only the gamification points earned or lost through an action of the user in the app are reported live.

Next steps​