Quick Start Guide
- iOS Tracker
- Android Tracker
Installationβ
The iOS Tracker SDK can be installed using various dependency managers.
Swift Package Manager (Recommended)
To install Snowplow Tracker with SPM:
- In Xcode, select File > Swift Packages > Add Package Dependency.
- Add the url where to download the library: https://github.com/snowplow/snowplow-objc-tracker
Cocoapods
To install Snowplow Tracker with Cocoapods:
- Make sure that Cocoapods is installed on your system and correctly configured for your app.
- Add the iOS Tracker SDK among the dependencies of your
Podfile
:
pod 'SnowplowTracker', '~> 2.0'
- Run the command
pod install
to add the tracker to your app project.
Carthage
To install Snowplow Tracker with Carthage:
- Make sure that Carthage is installed on your system and correctly configured for your app.
- Add the iOS Tracker SDK among the dependencies of your
Cartfile
:
github "snowplow/snowplow-objc-tracker" ~> 2.0
- Run the command
carthage update
and drag the appropriate frameworks from theCarthage/build
folder to your app project.
Supported System Version
The iOS Tracker SDK supports iOS 9.0+, macOS 10.9+, tvOS 9.0+ and watchOS 2.0+
Instrumentationβ
Once the tracker SDK is correctly set as a dependency in your app project you have to instrument the tracker:
- In your application delegate
AppDelegate.swift
addimport SnowplowTracker
. - In the
application(_:didFinishLaunchingWithOptions:)
method, set up the SDK as follows:
let tracker = Snowplow.createTracker(namespace: "appTracker", endpoint: COLLECTOR_URL, method: .post)
- It creates a tracker instance which can be used to track events like this:
let event = Structured(category: "Category_example", action: "Action_example")
tracker.track(event)
If you prefer to access the tracker when the reference is not directly accessible, you can use the defaultTracker
:
Snowplow.defaultTracker().track(event)
The tracker has a default configuration where some settings are enabled by default:
- session tracking
- screen tracking
- platform contexts (mobile specific context fields)
You can override the default configuration with a fine grained configuration when you create the tracker:
let networkConfig = NetworkConfiguration(endpoint: COLLECTOR_URL, method: .post)
let trackerConfig = TrackerConfiguration()
.base64Encoding(false)
.sessionContext(true)
.platformContext(true)
.lifecycleAutotracking(true)
.screenViewAutotracking(true)
.screenContext(true)
.applicationContext(true)
.exceptionAutotracking(true)
.installAutotracking(true)
let sessionConfig = SessionConfiguration(
foregroundTimeout: Measurement(value: 30, unit: .minutes),
backgroundTimeout: Measurement(value: 30, unit: .minutes)
)
Snowplow.createTracker(
namespace: "appTracker",
network: networkConfig,
configurations: [trackerConfig, sessionConfig]
);
Installationβ
The Android Tracker SDK is available on Maven Central and can be installed using Gradle.
Gradle
Add into your build.gradle
file:
dependencies {
...
// Snowplow Android Tracker
implementation 'com.snowplowanalytics:snowplow-android-tracker:2.+'
// In case 'lifecycleAutotracking' is enabled
implementation 'androidx.lifecycle-extensions:2.2.+'
...
}
Supported System Version
The Android Tracker SDK supports Android 5 (API level 21+)
Instrumentationβ
Once the tracker SDK is correctly set as a dependency in your app project you have to instrument the tracker:
- In your
Application
subclass, set up the SDK as follows:
TrackerController tracker = Snowplow.createTracker(context, "appTracker", COLLECTOR_URL, HttpMethod.POST);
- It creates a tracker instance which can be used to track events like this:
Event event = new Structured("Category_example", "Action_example");
tracker.track(event);
If you prefer to access the tracker when the reference is not directly accessible, you can use the defaultTracker
:
Snowplow.getDefaultTracker().track(event);
The tracker has a default configuration where some settings are enabled by default:
- session tracking
- screen tracking
- platform contexts (mobile specific context fields)
You can override the default configuration with a fine grained configuration when you create the tracker:
NetworkConfiguration networkConfig = new NetworkConfiguration(COLLECTOR_URL, HttpMethod.POST);
TrackerConfiguration trackerConfig = new TrackerConfiguration("appId")
.base64Encoding(false)
.sessionContext(true)
.platformContext(true)
.lifecycleAutotracking(true)
.screenViewAutotracking(true)
.screenContext(true)
.applicationContext(true)
.exceptionAutotracking(true)
.installAutotracking(true);
SessionConfiguration sessionConfig = new SessionConfiguration(
new TimeMeasure(30, TimeUnit.SECONDS),
new TimeMeasure(30, TimeUnit.SECONDS)
);
Snowplow.createTracker(context,
"appTracker",
networkConfig,
trackerConfig,
sessionConfig
);