Track

Learn about the methods for tracking user activity.

We recommend the use of a helper class to abstract the Tealium implementation from the rest of your app. This will give you a single entry point from which to initialize and make tracking calls. This approach allows you to update the code in your helper file and not in every single ViewController or Swift file.

trackView()

This code block will track a screen view on the homescreen, passing a Dictionary containing two key-value pairs, the first representing the customer id, and the second, an array of product IDs purchased in this transaction (in this instance, containing 1 product only). You may optionally specify a completion block, but you may pass nil if you don’t need special completion handling.

track()

This code block will track a button click on “Buy Now”, passing a Dictionary containing a single key-value pair, representing the customer id. You may optionally specify a completion block, but you may pass nil if you don’t need special completion handling.

Persistent Data

Persistent data storage should be used for those variables which rarely change during the app’s lifecycle, but are required to be sent on every tracking call. An example of this may be a customer ID that stays the same until the user logs out. Persistent data remains set across multiple app launches (since it is stored on disk), and can only be modified by deleting the data through the persistent data API, or overwriting an existing key with a new value. Persistent data is merged with any dictionary passed in each tracking call (trackView or track), and sent to any enabled dispatch services.

Persistent Data storage is backed by either UserDefaults or File Storage, depending on the modules currently enabled.

tealium?.persistentData()?.add(data: ["customer_id":"1234567890-a"])

Volatile Data

Volatile data storage should be used for those variables that do not change during a single launch of the app, but may change for future launches. An example of this may be some sort of session ID, which is regenerated each time the user relaunches the app. Volatile data works in a similar way to persistent data, except that it is only kept in main memory, and never written to disk. Thus, force closing an app will clear all volatile data previously set. From the point it is set, volatile data will be sent on each subsequent tracking call, and its data merged with any Dictionary passed in to the tracking call.