New in CUX: Mobile Analytics. Analyze real user behavior inside your app. Learn More

Identify users and track Flutter custom events

Identify users and track Flutter custom events

Browse topics

On this page

Connect activity to an internal account ID and record outcomes your Flutter app confirms, such as a completed checkout. Initialize the SDK and allow collection before using these examples.

Package covered: cux_analytics_sdk 0.0.27.

Identify users

After your app knows which account is active:

CuxAnalytics.setUserProperties(
  userId: 'account-123',
  params: {'plan': 'pro'},
);

Identification is optional. Use an internal ID, and test logout and account switching rather than assuming stop/resume clears identity.

Track custom events

Send the event when the app confirms the outcome:

CuxAnalytics.trackEvent(
  eventName: 'checkout_completed',
  params: {'currency': 'USD', 'plan': 'pro'},
  label: 'subscription',
);

The public API uses string parameters. Native Android's trackEventTyped() is not this Flutter package's API.

Avoid duplicate events

Send an event from the handler that confirms the outcome. Do not also send it from a widget build or a navigation callback. Check retries and repeated callbacks separately.

Screenshot masking does not filter identifiers, user properties or event parameters. Use only the context you need. See Identify mobile users and Track mobile custom events for the shared guidance.

Verify users and events

Use two synthetic accounts. Complete an action once and check the active identifier, event name, label and string parameters in CUX. Repeat the journey without completing the action and confirm that the success event does not appear.

Test login, logout and switching accounts on the same device. If identity clearing is not documented for your integration, confirm the supported approach with CUX before relying on it on shared devices.

For missing data, follow Flutter troubleshooting.