Set up your tracking
Setting up Snowplow e-commerce tracking starts with installing and setting up the tracker as for any Snowplow implementation. Read more here.
Step 1: Install tracker dependency
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-ios-tracker
Step 2: Create the tracker
In your app, create 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: "https://snowplow-collector-url.com" )
The URL path for your collector endpoint should include the protocol, “http” or “https”. If not included in the URL, “https” connection will be used by default. The tracker namespace will be attached to all events, and is especially useful when multiple trackers are instrumented in the same app (with different configuration or endpoint).
It creates a tracker instance which can be used to track events like this:
let event = PromotionViewEvent(promotion: PromotionEntity(id: "IP1234")) 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)
Step 1: Install tracker dependency
The Android Tracker SDK can be installed using Gradle.
Gradle
Add into your build.gradle
file:
dependencies {
...
// Snowplow Android Tracker
implementation 'com.snowplowanalytics:snowplow-android-tracker:5.+'
// In case 'lifecycleAutotracking' is enabled
implementation 'androidx.lifecycle-extensions:2.2.+'
...
}
Step 2: Create the tracker
In your app, create the tracker.
In your
Application
subclass, set up the SDK as follows:val tracker = Snowplow.createTracker( applicationContext, // Android context (LocalContext.current in Compose apps) "appTracker", // namespace "https://snowplow-collector-url.com" // Event collector URL )
The URL path for your collector endpoint should include the protocol, “http” or “https”. If not included in the URL, “https” connection will be used by default. The tracker namespace will be attached to all events, and is especially useful when multiple trackers are instrumented in the same app (with different configuration or endpoint).
It creates a tracker instance which can be used to track events like this:
val event = PromotionViewEvent(PromotionEntity(id = "IP1234")) 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)
Step 1: Install tracker dependency
The Android Tracker SDK can be installed using Gradle.
Gradle
Add into your build.gradle
file:
dependencies {
...
// Snowplow Android Tracker
implementation 'com.snowplowanalytics:snowplow-android-tracker:5.+'
// In case 'lifecycleAutotracking' is enabled
implementation 'androidx.lifecycle-extensions:2.2.+'
...
}
Step 2: Create the tracker
In your app, create the tracker.
In your
Application
subclass, set up the SDK as follows:TrackerController tracker = Snowplow.createTracker( getApplicationContext(), // Android context "appTracker", // namespace "https://snowplow-collector-url.com" // Event collector URL );
The URL path for your collector endpoint should include the protocol, “http” or “https”. If not included in the URL, “https” connection will be used by default. The tracker namespace will be attached to all events, and is especially useful when multiple trackers are instrumented in the same app (with different configuration or endpoint).
It creates a tracker instance which can be used to track events like this:
Event event = new PromotionViewEvent(new PromotionEntity("IP1234")); 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);