Swift Module: Autotracking

Swift Module: Autotracking

by jason_koo on ‎02-06-2017 11:45 AM - edited on ‎06-01-2017 10:31 AM by Community Manager (446 Views)
 
This guide shows how to install and use the Autotracking module from the Tealium Swift library. The Autotracking module tracks all relevant app activity, such as views, taps, and swipes, are tracked. 
 
The following topics are covered:
Table of Contents Placeholder

Features

  • Automatically trigger track calls from UIViewController view appearances
  • Automatically trigger track calls for UI Events (ie button taps)
  • Includes delegate methods for reporting or suppressing autotracked data

Requirements

  • Tealium for Swift version 1.1.0+
  • Objective-C Bridging header
  • Access to Apple's UIKit framework & UIApplication on the target platform (iOS, tvOS)

Installation & Configuration

The Autotracking module is located in the tealium/autotracking folder of the main repo.  Add the entire autotracking folder to the target project.  The core library will automatically instantiate the module if a bridging header includes the following:

#import "UIApplication+TealiumTracker.h"
#import "UIViewController+TealiumTracker.h"

To disable the module, do one of the following:

  • delete or dereference the 'autotracking' folder files from the target project
  • set the module's configuration 'enabled' property to 'false'

Methods

tealiumAutotrackingShouldTrack

tealiumAutotrackingShouldTrack(data: [String:Any]) -> Bool
Parameters Description Example Value
data Dictionary with String keys and Any value type. Values are typically String or [String] ["key":"value"]
// SAMPLE
func tealiumAutotrackShouldTrack(data: [String:Any]) -> Bool {
// Filter out View appearance events
if data["tealium_event_type"] as? String == "view" {
return false
}
return true
}

tealiumAutotrackDidComplete

tealiumAutotrackDidComplete(success:Bool, info:[String:Any]?, error:Error?)
Parameters Description Example Value
success If the autotracked triggered call was successful. true
info Optional information as a [String:Any] dictionary regarding the track call. Typically holds delivery type info, final call format, and the payload (the data dictionary used to generate the call).  
error Error, if any, returned.  
// SAMPLE
func tealiumAutotrackDidComplete(success:Bool, info:[String:Any]?, error:Error?) {
print("Tealium autotrack call completed with info: \(info)")
}

Data Layer Variables

The module adds the following variables to the data layer for all tracking calls:

Variable Description Type Example
autotracked String of Boolean String "true"

Change Log

Build 1

  • UI Event Autotracking
  • UIViewController viewDidAppear Autotracking
  • Completion & suppression delegate methods