Search documentation...

K
ChangelogBook a demoSign up

Flutter SDK

The Flutter SDK makes it easy to track events from all types of Flutter applications.

Installation

The Flutter SDK is hosted on pub.dev.

You may install the SDK by adding it to your pubspec.yaml file:

flutter pub add hightouch_events

Initialization

You should initialize the SDK in the top-level app state and store it in a variable for use across your application. For example, you may want to initialize it in your app delegate.

Example:

final analytics = createClient(Configuration("WRITE_KEY"));

Configuration options:

OptionTypeDescription
writeKeyStringYour Hightouch write key.
apiHostStringThe API host to send the tracked events to.
trackApplicationLifecycleEventsBoolWhether to automatically track application lifecycle events (like opening the application). Defaults to false.

API

Identify

The analytics.identify method sends an identify event.

Example usage:

analytics.identify(userId: "user-123", userTraits: UserTraits(email: "user@example.com"));

Track

The analytics.track method sends a track event.

Example usage:

analytics.track("View Product", properties: {"productId": 123});

Screen

The analytics.screen method sends a screen event.

Example usage:

analytics.screen("Home");

Group

The analytics.group method sends a group event.

Example usage:

analytics.group("group-123", groupTraits: GroupTraits(name: "Group 123"));

Flush

The Flutter SDK buffers events locally before sending them to Hightouch's servers. This minimizes the number of requests made by the SDK and makes the tracking non-blocking.

To force the local buffer to be sent to Hightouch immediately call the flush() method.

Reset

The reset method resets the identify and group for the local session. Specifically, it resets the anonymousId, userId, referrer, and traits.

The reset method should be called when users log out. This way, if the user logs back in with another account, the userIds and traits from the different sessions remain separate.

Ready to get started?

Jump right in or a book a demo. Your first destination is always free.

Book a demoSign upBook a demo

Need help?

Our team is relentlessly focused on your success. Don't hesitate to reach out!

Feature requests?

We'd love to hear your suggestions for integrations and other features.

Last updated: Oct 7, 2024

On this page

InstallationInitializationAPIIdentifyTrackScreenGroupFlushReset

Was this page helpful?