Skip to content
SDK

Event Tracking

Track events and screen views for targeting and analytics.

Event Tracking

Events are the signals that tell Setgreet what your users are doing in your app. By tracking events, you unlock event-based flow triggers, richer analytics, and integration forwarding.

Tracking custom events

Use the trackEvent method to record an event with an optional properties dictionary:

// iOS
Setgreet.trackEvent(event: "purchase_completed", properties: [
    "amount": 49.99,
    "currency": "USD",
    "plan": "pro"
])
// Android
Setgreet.trackEvent("purchase_completed", mapOf(
    "amount" to 49.99,
    "currency" to "USD",
    "plan" to "pro"
))
// React Native
import { trackEvent } from '@setgreet/react-native-sdk';

trackEvent('purchase_completed', {
  amount: 49.99,
  currency: 'USD',
  plan: 'pro',
});
// Flutter
await Setgreet.trackEvent("purchase_completed", {
  "amount": 49.99,
  "currency": "USD",
  "plan": "pro",
});

Event names should be descriptive and consistent. Use snake_case as a convention (for example, feature_activated, profile_completed, item_added_to_cart).

Screen tracking

Track screen views to enable screen-based flow triggers. Call trackScreen whenever a user navigates to a new screen in your app:

// iOS
Setgreet.trackScreen(name: "settings")
// Android
Setgreet.trackScreen("settings")
// React Native
import { trackScreen } from '@setgreet/react-native-sdk';

trackScreen('settings');
// Flutter
await Setgreet.trackScreen("settings");

Screen names should match across platforms if you want consistent targeting. For example, use "home" on both iOS and Android rather than "HomeViewController" on iOS and "HomeActivity" on Android.

How events are used

Events power three key features:

1. Flow triggers

You can configure a flow to display when a specific event is fired. For example:

  • Show a rating prompt when order_delivered fires.
  • Show an upgrade nudge when free_limit_reached fires.
  • Show a feature tour when feature_page_viewed fires.

Event-based triggers can include property filters. For example, trigger a flow only when purchase_completed fires AND amount is greater than 100.

2. Analytics

Events contribute to flow analytics and conversion goals. If a flow's conversion goal is feature_activated, Setgreet tracks how many users who saw the flow subsequently fired that event.

3. Integrations

Events can be forwarded to third-party tools through integrations. Setgreet events (flow displays, completions, component interactions) are forwarded automatically. Custom events you track via trackEvent are available for matching against conversion goals.

The SDK batches events and sends them to the server periodically for efficiency. Events are persisted locally and retried if the network is unavailable, so no data is lost.

Best practices

  • Track meaningful moments. Focus on events that represent user intent or milestones -- sign up, feature use, purchase, error encountered. Avoid tracking every tap or scroll.
  • Keep event names stable. Changing event names breaks flow triggers that reference them. Treat event names as a contract between your app and your Setgreet configuration.
  • Use properties for context. Instead of creating separate events like plan_upgrade_pro and plan_upgrade_enterprise, use a single plan_upgraded event with a plan property.
  • Track screens consistently. Use the same screen names across iOS, Android, React Native, and Flutter so that screen-based triggers work across all platforms.

On this page