Purpose
Object provides a central place for configuring tracking options for the Tealium API. Individual modules provide their own extensions for the TealiumConfig class if they are enabled.
Supported Platforms
iOS
tvOS
watchOS
macOS
Installation
Included with the TealiumCore framework
CocoaPods
pod 'tealium-swift/TealiumCore'
import TealiumSwift
Carthage
TealiumCore.framework
import TealiumCore
Public API
TealiumConfig
Constructor for a TealiumConfig object. This object is required to initialize the library for your specific account.
TealiumConfig(account:String, profile:String, environment:String, optionalData:Dictionary, dataSource:String)
Parameters
Type
Description
account
String
Tealium account name
profile
String
Tealium profile name (usually "main")
environment
String
Tealium environment: "dev", "qa", or "prod"
optionalData
[String: Any]?
Parameter is optional, and may be omitted if you don't need it. See explanation on optionalData below
datasource
String
Datasource key (available from UDH). Optional.
// SAMPLE
// standard basic config object
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// with optionaldata and datasource
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod", optionalData: nil, datasource: "2f5s1")
// with datasource but no optionalData
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod", datasource: "2f5s1")
optionalData
Allows certain default behavior to be overridden at init time. Generally, it is better to use the override methods, rather than explicitly specifying an optionalData object.
OptionalData key
Data Type
Function
TealiumTagManagementConfigKey.maxQueueSize
Int
Integer representing the maximum queue size for cached (offline) events
TealiumTagManagementConfigKey.overrideURL
String
Override URL for Tag Management webview
TealiumCollectKey.overrideCollectUrl
String
Override URL for Tealium Collect HTTPS requests
TealiumDeviceDataModuleKey.isMemoryReportingEnabled
Bool
Turns low-level device memory reporting on (true) or off (false - default)
TealiumAttributionKey.isSearchAdsEnabled
Bool
Enables support for the Apple Search Ads API in the attribution module (default off - false)
setModulesList
The list of modules to be enabled or disabled. (see Modules List)
setModulesList(TealiumModulesList)
Parameters
Type
Description
modulesList
TealiumModulesList*
List of modules to enable or disable
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// blacklists the autotracking module
let modulesList = TealiumModulesList(isWhitelist: false, moduleNames: ["autotracking"]
config.setModulesList(modulesList)
*TealiumModulesList struct
Parameters
Type
Description
isWhiteList
Bool
Determines if modules list is a blacklist ( false ) or a whitelist ( true )
modulesList
[String]
Array of module names to enable or disable
getModulesList
Returns the current module list object. (see Modules List)
getModulesList() -> TealiumModulesList
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// blacklists the autotracking module
let modulesList = config.getModulesList()
setLogLevel
Sets a new log level
setLogLevel(logLevel: TealiumLogLevel)
Parameters
Type
Description
logLevel
TealiumLogLevel
New Log Level (see Swift Module: Logger)
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// .none .errors .warnings .verbose
let newLogLevel = TealiumLogLevel.errors
config.setLogLevel(logLevel: newLogLevel)
getLogLevel
Returns the current log level (see Swift Module: Logger)
getLogLevel() -> TealiumLogLevel
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let logLevel = config.getLogLevel()
setTagManagementOverrideURL
Overrides the default URL used by the non-rendered UIWebView used by the Tag Management module. This should generally be avoided unless you are self-hosting your Tealium JavaScript files.
setTagManagementOverrideURL(string: String)
Parameters
Type
Description
string
String
String representing a URL to be loaded by the Tealium UIWebView
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let url = "https://tags.mycdn.com/utag/myaccount/myprofile/myenv/mobile.html"
config.setTagManagementOverrideURL(string: url)
setTagManagementQueueSize
Sets the maximum tag management queue size
setTagManagementQueueSize(to: Int)
Parameters
Type
Description
to
Int
Maximum queue size
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.setTagManagementQueueSize(to: 1)
setCollectOverrideURL
Overrides the Tealium Collect URL to send data to a different endpoint.
setCollectOverrideURL(string:String)
Parameters
Type
Description
string
String
String representing a URL for the Collect module to send data to. Can be used to force data collection to stay within a particular region (e.g. EU Central/Germany)
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// force override tealium collect base URL to EU Central
let url = "https://collect-eu-central-1.tealiumiq.com/vdata/i.gif?"
config.setCollectOverrideURL(string: url)
setMemoryReportingEnabled
Enables or disables memory reporting in the DeviceData module (default: disabled).
setMemoryReportingEnabled(Bool)
Parameters
Type
Description
enabled
Bool
Enables or disables memory reporting in the Device Data module.
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.setMemoryReportingEnabled(true)
isMemoryReportingEnabled
Returns a Bool indicating whether memory reporting is currently enabled or disabled.
isMemoryReportingEnabled() -> Bool
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let enabled = config.isMemoryReportingEnabled()
setSearchAdsEnabled
Enables or disables memory reporting in the DeviceData module (default: disabled).
setSearchAdsEnabled(Bool)
Parameters
Type
Description
enabled
Bool
Enables or disables Apple Search Ads API in the Attribution module
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.setSearchAdsEnabled(true)
isSearchAdsEnabled
Returns a Bool indicating whether the Apple Search Ads API is currently enabled or disabled in the Attribution module.
isSearchAdsEnabled() -> Bool
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let enabled = config.isSearchAdsEnabled()
disableRemoteHTTPCommand
Disables the built-in remote HTTP command (see Swift Module: RemoteCommands).
disableRemoteHTTPCommand()
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.disableRemoteHTTPCommand()
enableRemoteHTTPCommand
Enables the built-in remote HTTP command (see Swift Module: RemoteCommands).
enableRemoteHTTPCommand()
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.enableRemoteHTTPCommand()
dispatchQueue
Returns the current dispatch queue used for all Tealium processes.
dispatchQueue() -> DispatchQueue
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let dispatchQueue = config.dispatchQueue()
setDispatchQueue
Sets a new dispatch queue for Tealium to use. Not recommended. Default is DispatchQueue.main.
setDispatchQueue(DispatchQueue)
Parameters
Type
Description
DispatchQueue
DispatchQueue
A dispatch queue to be used by Tealium
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let dispatchQ = DispatchQueue(label: "com.tealium.myqueue")
config.setDispatchQueue(dispatchQ)
defaultDispatchQueue
Returns the default dispatch queue (DispatchQueue.main).
defaultDispatchQueue() -> DispatchQueue
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let dispatchQueue = config.dispatchQueue()
addDelegate
Adds a new delegate conforming to the TealiumDelegate protocol.
addDelegate(Delegate)
Parameters
Type
Description
delegate
TealiumDelegate
A class conforming to the TealiumDelegate protocol
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
// assuming current module has implemented the TealiumDelegate protocol
config.addDelegate(self)
delegates
Returns an array of the currently-enabled delegates.
delegates() -> [TealiumDelegate]
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let delegates = config.delegates()
setConnectivityRefreshEnabled
If enabled (default), the connectivity module will check for a connection at a specified interval (controlled via setConnectivityRefreshInterval ). Queued dispatches will then be sent as soon as a connection is resumed.
setConnectivityRefreshEnabled(Bool)
Parameters
Type
Description
enabled
Bool
Sets the enabled state of the connectivity refresh feature in the Connectivity module. Default true
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config.setConnectivityRefreshEnabled(true) // set to false to disable this feature
setConnectivityRefreshInterval
Sets the default connectivity refresh interval in seconds. Default is 30 seconds if not set on the TealiumConfig instance.
setConnectivityRefreshInterval(Int)
Parameters
Type
Description
interval
Int
Number of seconds after which the connectivity module will test for connectivity if the device is offline
// sample
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
config. setConnectivityRefreshInterval(5) // sets interval to 5 seconds
addRemoteCommand
Adds remote commands for later execution
addRemoteCommand(TealiumRemoteCommand)
Parameters
Type
Description
command
TealiumRemoteCommand
Instance of a TealiumRemoteCommand to be added
// run prior to Tealium initialization
#if os(iOS)
let remoteCommand = TealiumRemoteCommand(commandId: "test",
description: "test") { response in
print("Remote Command 'test' executed")
}
config.addRemoteCommand(remoteCommand)
#endif
getRemoteCommands
Returns an array of remote commands set on the TealiumConfig instance
getRemoteCommands() ->[TealiumRemoteCommand]?
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod")
let remoteCommands = config.getRemoteCommands()
setLegacyDispatchMethod
Forces Collect module to use the legacy "vdata" GET request dispatcher instead of the default "/event" POST request dispatcher.
setLegacyDispatchMethod(Bool)
Parameters
Type
Description
_
Bool
If true , forces Collect module to use legacy "vdata" dispatch method
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev/qa/prod") config.setLegacyDispatchMethod(true)
Future Improvements
No planned changes.
Change Log
1.6.5
TealiumModulesList is no longer required if you are only importing the specific modules you require. It will, however, continue to function as expected if present.
Added methods for Connectivity module
1.4.0
Documentation updates
Additional config methods/properties added for new module functionality
... View more