Designing how and what to track in your app is an important decision. Check out our docs about tracking design here.
The following steps will guide you through setting up the Flutter tracker in your project and tracking a simple event.
Add the Snowplow tracker as a dependency to your Flutter application:
flutter pub add snowplow_tracker
This will add a line with the dependency like to your pubspec.yaml:
Import the package into your Dart code:
Installation on Web
index.html file. Please load the JS tracker with the Snowplow tag as described in the official documentation. Do not change the global function name
snowplow that is used to access the tracker – the Flutter APIs assume that it remains the default as shown in documentation.
3.2 or newer. You may also refer to the example project in the Flutter tracker repository to see this in action.
Instantiate a tracker using the
Snowplow.createTracker function. You may create the tracker in the
initState() of your main widget. At its most basic, the function takes two required arguments:
endpoint. Tracker namespace identifies the tracker instance, you may create multiple trackers with different namespaces. The endpoint is the URI of the Snowplow collector to send the events to.
SnowplowTracker tracker = await Snowplow.createTracker(
There are additional optional arguments to configure the tracker. To learn more about configuring how events are sent, check out this page.
To track events, simply instantiate their respective types (e.g.,
Structured) and pass them to the
Testing that your event tracking is properly configured can be as important as testing the other aspects of your app. It confirms that you are generating the events you expect.
We provide two types of pipeline for testing and debugging. Snowplow Mini is especially useful in manual schema and pipeline testing. Snowplow Micro is a minimal pipeline designed to be used as part of your app's automated test suite.