- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
NOTE: This article is deprecated. Please see: https://community.tealiumiq.com/t5/Swift/tkb-p/swift
This guide shows how to add Tealium to your Swift app to track user activity. Before you begin, here's a video introduction to the platform:
The code for the Tealium Swift library can be easily installed using Carthage or downloaded from on Github. The repository contains the following modules:
device_uuid
and tealium_vid
to tracked data (required for AudienceStream visitor stitching).device_advertising_id
(identifierForVendor) to tracked data. Please note that using this module requires an additional app store submission step.Carthage is a simple way to manage dependencies in Swift. Install Carthage manually or via Homebrew with the following terminal command:
brew install carthage
Then add the following entry to the Cartfile in your project:
github "tealium/tealium-swift"
Then update from the terminal with:
carthage update
This will produce frameworks for the following platforms:
To build only for a particular platform, use Carthage's --platform argument:
carthage update --platform ios
The Carthage built frameworks do not include the Attribution module by default.
The code for the Tealium Swift library is stored on Github. You must download and install the library.
Import the Tealium folder into your project and add the desired modules. The library employs a drag-and-drop modular architecture when the source files are referenced directly. Each subfolder within tealium-swift/tealium
contains all the files related to that module. The Core submodule is required and the Collect submodule is highly recommended.
To disable a previously added module, either remove it from the project or manually edit the module file and change the method moduleConfig()
to return false.
Watch this video for an overview of the installation and setup of the code:
The Tealium instance must be configured with the following parameters:
// Minimum setup
var config = TealiumConfig(account: "your_account",
profile: "your_profile",
environment: "prod")
let tealium = Tealium(config: config)
// With Datasource module (default included with framework builds)
var configWithDatasource = TealiumConfig(account: "your_account",
profile: "your_profile",
environment: "prod",
datasource: "abc123")
let tealiumWithDatasource = Tealium(config: configWithDatasource)
All tracking is done with the track() method, which takes the following parameters:
TealiumTrackType.view
- for tracking screen viewsTealiumTrackType.activity
- (default) for tracking non-view user eventsThe Collect submodule must be added to enable tracking calls.
// Basic track call
tealium.track(title:"someEvent",
data:nil,
completion:nil);
// With optional data
let data = [ "someKey" : "someValue" ]
tealium.track(title:"someEvent",
data:data,
completion:nil);
// With optional callback
tealium.track(title:"someEvent",
data: null,
completion: { (success, info, error) in
// Any monitoring or follow-up code here
})
// Specifying track type - ie appearance of a UIView
tealium.track(type:TealiumTrackType.view,
title: "screenView",
data: nil,
completion: nil)
Copyright All Rights Reserved © 2008-2023