1. Home
  2. Blog
  3. Releases

Snowplow tracker for Flutter apps

We are pleased to announce the first release of our tracker for Flutter apps. The package is released on pub.dev as snowplow_tracker.

Version 0.1.0 brings suport for Flutter apps for Web, iOS, and Android. It does so by building on top of our mature trackers for the respective platforms (all in version 3). This provides it a solid and well-tested foundation with a range of features.

Using the tracker

To install in your project, add snowplow_tracker as dependency to your project. If using the tracker within a Flutter app for Web, you will also need to import the Snowplow JavaScript Tracker in your index.html file. Please load the JS tracker with the Snowplow tag as described in the official documentation.

Once installed, import the package into your Dart code:

import 'package:snowplow_tracker/snowplow_tracker.dart'

Instantiate a tracker using the Snowplow.createTracker function:

SnowplowTracker tracker = await Snowplow.createTracker(
    namespace: 'ns1',
    endpoint: 'http://...'

To track events, simply instantiate their respective types (e.g., ScreenViewSelfDescribingStructured) and pass them to the tracker.track or Snowplow.track methods. Please refer to the documentation for specification of event properties.

SnowplowTracker tracker = await Snowplow.createTracker(
// Tracking a screen view event
    id: '2c295365-eae9-4243-a3ee-5c4b7baccc8f',
    name: 'home',
    type: 'full',
    transitionType: 'none'));

Check out the Snowplow Docs section for more information about setting up and using the tracker.

Automatic tracking of view events

The tracker provides an option to automatically track view events when currently active pages change through the Navigator API. When an observer is registered in an app’s main widget, the tracker listens for changes in currently active routes such as those triggered by calling Navigator.push(). Upon these changes, it tracks page or screen view events depending on the configuration of the tracker.

To activate this feature, one has to register a SnowplowObserver retrieved from the tracker instance. The retrieved observer can be added to navigatorObservers in MaterialApp:

  navigatorObservers: [tracker.getObserver()],

Check out the Snowplow Docs section for more information.

Support for mobile and Web data models

The tracker gives you the option to choose a data model that best fits your app. It provides two options:

  1. You may follow the mobile data model on all platforms and track screen views events. This behaviour is supported across all platforms – Android, iOS, and Web. It is the default option and is suitable for most multi-platform Flutter apps and progressive Web apps.
  2. You may choose to adapt the Web data model on Web while using the mobile data model on Android and iOS. In this case, page view and page ping events are tracked on Web. This approach is best suitable for apps that are primarily built for the Web and provide a dedicated Web user interface.

To make use of the Web data model on Web, make sure to configure WebActivityTracking during tracker initialization:

final SnowplowTracker tracker = await Snowplow.createTracker(
    trackerConfig: const TrackerConfiguration(
        webPageContext: false,
        webActivityTracking: WebActivityTracking(minimumVisitLength: 15, heartbeatDelay: 10)));

We are very keen to hear your feedback to shape the future releases of this tracker! Please feel free to open discourse topics with ideas, and add issues and bug reports to the repo. We also welcome contributions and PRs. If in doubt, open an issue or a discourse post to ask about your contribution.

More about
the author

Matúš Tomlein
Matúš Tomlein

Matus is a software engineer in the Snowplow tracker SDKs team. He has worked on various trackers including the JavaScript, mobile, and C++ trackers.

View author

Ready to start creating rich, first-party data?

Image of the Snowplow app UI