The package provides a single method to initialize and configure a new tracker, the
Snowplow.createTracker method. It accepts configuration parameters for the tracker and returns a
SnowplowTracker tracker = await Snowplow.createTracker(
trackerConfig: const TrackerConfiguration(...),
gdprConfig: const GdprConfiguration(...),
subjectConfig: const SubjectConfiguration(...));
The method returns a
SnowplowTracker instance. This can be later used for tracking events, or accessing tracker properties. However, all methods provided by the
SnowplowTracker instance are also available as static functions in the
Snowplow class but they require passing the tracker namespace as string.
The only required attributes of the
Snowplow.createTracker method are
namespace used to identify the tracker, and the Snowplow collector
endpoint. Additionally, one can configure the HTTP method to be used when sending events to the collector, as well as a custom POST path, and provide configuration by instantiating classes for
GdprConfiguration. By default, events are sent by POST. The following arguments are accepted by the
|Tracker namespace to identify the tracker.|
|URI for the Snowplow collector endpoint.|
|HTTP method to use: |
|Custom POST path.|
|Map of custom HTTP headers to add to requests to the collector.|
|Configuration of the tracker and the core tracker properties.|
|Determines the GDPR context that will be attached to all events sent by the tracker.|
|Subject information about tracked user and device that is added to events.|
|Configuration for how the events are sent.|
The ability to set
customPostPath was added in v0.2.0. Setting a custom POST path can be useful in avoiding adblockers; it replaces the default "com.snowplowanalytics/snowplow/tp2". Your event collector must also be configured to accept the custom path.
EmitterConfiguration class was added in v0.3.0.
Configuration of tracker properties:
TrackerConfiguration provides options to configure properties and features of the tracker. In addition to setting the app identifier and device platform, the configuration enables turning several automatic context entities on and off.
|Identifier of the app.||✔||✔||✔||null on Web, bundle identifier on iOS/Android|
|The device platform the tracker runs on. Available options are provided by the ||✔||✔||✔||"web" on Web, "mob" on iOS/Android|
|Indicates whether payload JSON data should be base64 encoded.||✔||✔||✔||true|
|Indicates whether platform (mobile) entity should be attached to tracked events.||✔||✔||true|
|Indicates whether geo-location entity should be attached to tracked events.||✔||✔||✔||false|
|Indicates whether session entity should be attached to tracked events.||✔||✔||✔||true|
|Indicates whether a context entity about current web page should be attached to tracked events.||✔||true|
|Indicates whether screen entity should be attached to tracked events.||✔||✔||true|
|Indicates whether application entity should be attached to tracked events.||✔||✔||true|
|Enables activity tracking using page views and pings on the Web.||✔||true|
|Anonymizes certain user identifiers.||✔||✔||✔||false|
|Indicates whether the lifecycle entity and foreground and background events should be autotracked.||✔||✔||false|
The ability to enable
userAnonymisation, or the screen and application context entities, was added in v0.3.0.
The ability to enable
lifecycleAutotracking was added in v0.5.0.
WebActivityTracking property configures page tracking on Web. Initializing the configuration will inform
SnowplowObserver observers (see section on auto-tracking in "Tracking events") to auto track
PageViewEvent events instead of
ScreenView events on navigation changes. Further, setting the
heartbeatDelay properties of the
WebActivityTracking instance will enable activity tracking using 'page ping' events on Web.
Activity tracking monitors whether a user continues to engage with a page over time, and record how they digest content on the page over time. That is accomplished using 'page ping' events. If activity tracking is enabled, the web page is monitored to see if a user is engaging with it. (E.g. is the tab in focus, does the mouse move over the page, does the user scroll etc.) If any of these things occur in a set period of time (
minimumVisitLength seconds from page load and every
heartbeatDelay seconds after that), a page ping event fires, and records the maximum scroll left / right and up / down in the last ping period. If there is no activity in the page (e.g. because the user is on a different browser tab), no page ping fires.
Lifecycle autotracking is only available on mobile apps (iOS and Android). When configured, a Lifecycle context entity is attached to all events. It records whether the app was visible or not when the event was tracked. In addition, a
Background event will be tracked when the app is moved to background, and a
Foreground event when the app moves back to foreground (becomes visible on the screen).
See this page for information about anonymous tracking.
Configuration of emitter properties:
This Configuration class was added in v0.3.0. Currently, the only property is
|Prevents tracking of server-side user identifiers.||✔||✔||✔||false|
Configuration of subject information:
Subject information are persistent and global information about the tracked device or user. They apply to all events and are assigned as event properties.
Some of the properties are only configurable on iOS and Android and are automatically assigned on the Web.
|Business ID of the user.||✔||✔||✔|
|Network user ID (UUIDv4).||✔||✔||Non-configurable, auto-assigned.|
|Domain user ID (UUIDv4).||✔||✔||Non-configurable, auto-assigned.|
|Custom user-agent. It overrides the user-agent used by default.||✔||✔||Non-configurable, auto-assigned.|
|The timezone label.||✔||✔||Non-configurable, auto-assigned.|
|The language set on the device.||✔||✔||Non-configurable, auto-assigned.|
|The screen resolution on the device.||✔||✔||Non-configurable, auto-assigned.|
|The screen viewport.||✔||✔||Non-configurable, auto-assigned.|
|The color depth.||✔||✔||Non-configurable, auto-assigned.|
The configured attributes are mapped to Snowplow event properties described in the Snowplow Tracker Protocol. They are mapped as follows:
GDPR context entity configuration:
Determines the GDPR context that will be attached to all events sent by the tracker.
|Basis for processing.||✔||✔||✔|
|ID of a GDPR basis document.||✔||✔||✔|
|Version of the document.||✔||✔||✔|
|Description of the document.||✔||✔||✔|