watchOS
Learn to install Tealium for watchOS.
Requirements
- Xcode 7+
- iOS 8.1+
- watchOS 2.0+
- Tealium for iOS installed in the host app
- 400KB available space in
.ipa
file size (this accounts for thetealium-ios
library needed in the host app) - Bitcode compliant framework
Sample Apps
To help familiarize yourself with the Tealium library, tracking methods, and best practice implementation, it is recommended to download the sample apps:
To abstract the Tealium implementation from the rest of your app, we recommend the use of the sample helper class. This gives you a single entry point from which to initialize and make tracking calls. It also allows you to update the code in your helper file, and not in every single header/method file.
Install
Install Tealium for watchOS as an extension application where TealiumIOS.framework
has been implemented in the host application.
-
Add
TealiumWATCHOSExtension.framework
to your project’s watchOS Extension target, and copy the framework to the project in the resulting dialog box. -
In the target’s General: Embedded Binaries section, add the framework:
TealiumWATCHOSExtension.framework
For Swift projects, add <TealiumWATCHOSExtension/TEALWKExtension.h>
to your bridging header file.
- Make sure all paths are as expected under Projects: Target: Build Settings.
Initialize
Once Tealium for watchOS is added to your project you are ready to start coding.
In the Application Delegate, or within a helper class setup method, add the following code to initialize the Tealium instance:
// Get Tealium instance
let config = TEALWKExtensionConfiguration.configuration()
guard let tealium = TEALWKExtension.newInstanceForKey("[INSTANCE]") else {
// Any additional failure response here
return
}
// Import area
#import <TealiumWATCHOSExtension/TealiumWATCHOS.h>
// Within a setup method
TEALWKExtensionConfiguration *config = [TEALWKExtensionConfiguration configuration];
config.logLevel = TEALLogLevelDev;
[TEALWKExtension newInstanceForKey:@"[INSTANCE]" configuration:config];
Track Views
Track screen views by calling trackViewWithTitle()
with two parameters: the name of the screen and (optionally) contextual view data.
In any UIViewController’s viewDidAppear()
method, use this code:
TEALWKExtension.instanceForKey("[hostTealiumInstanceKey]")?.trackViewWithTitle(NSStringFromClass(self.classForCoder), dataSources: [String:String]())
[[TEALWKExtension instanceForKey:@"[INSTANCE]"] trackViewWithTitle:NSStringFromClass([self class]) dataSources:@{}];
Track Events
Track non-view activity by calling trackEventWithTitle()
with two parameters: an event name and (optionally) contextual event data.
In any method that triggers or responds to an event trigger, use this code:
TEALWKExtension.instanceForKey("[INSTANCE]")?.trackEventwWithTitle("EVENT_NAME"), dataSources: [String:String]())
[[Tealium instanceForKey:@"[INSTANCE]"] trackEventWithTitle:@"EVENT_NAME" dataSources:@{@"optionalKey":@"optionalValue"}];
This page was last updated: January 7, 2023