The Tealium Swift library is designed around a modular architecture. Required modules must be specified when the library is initialized in the TealiumConfig instance.
All modules have a dependency on TealiumCore. Modules are separated into Collectors and Dispatchers depending on their purpose.
Collectors are modules that gather supplemental information from the device and append it to the data layer before it’s transmitted to the Tealium Customer Data Hub. Some collectors are included in the core library, while others are optional and installed as separate modules.
The following table lists the available collectors. Default collectors are denoted by a * next to the collector name.
These modules are included with the core library, but are enabled or disabled using the TealiumConfigcollectors property as described below
To add a Collector, specify it in the collectors property of the TealiumConfig instance:
To only use the default collectors, omit or comment out the config.collectors line from your initialization code.
Although custom collectors are generally not required, it is possible to build a custom collector by creating your own class conforming to the Collector protocol. The following example shows a simple collector that gathers the current weekday and appends it to the data layer for each tracking call.
Dispatchers are modules that send the data from your data layer and send it to a Tealium endpoint. The following dispatchers are currently available:
At least one dispatcher is required. If no dispatchers are specified, your data is not sent anywhere.
To add a Dispatcher, specify it in the dispatchers property of the TealiumConfig object:
importTealiumCoreimportTealiumLifecycleletconfig = TealiumConfig(account: "ACCOUNT",
// Add desired Collectors. Do not include if you want to use compiled Collectors
config.dispatchers = [Dispatchers.Collect]
Although custom dispatchers are generally not required, it is possible to build a custom Dispatcher by creating your own class conforming to the Dispatcher protocol. The following example shows a simple dispatcher that prints the event name for each track request. A custom Dispatcher may be useful if you wish to send data to your own custom endpoint in addition to the Tealium endpoints.
When you install with Carthage, you must explicitly import the modules you require. You may import all modules if you prefer, and use the module list, as described earlier, but your app is lighter if you only import the modules you need. See Install with Carthage for instructions on including/excluding specific modules.