Data Management
Learn how to manage persistent and volatile data.
Usage
Some variables are required on every event. To prevent having to manually add required variable data to every event, you have the option to store data as either volatile or persistent. Once data is stored, it will be appended to every event, including lifecycle events.
Learn more about Data Management.
Persistent Data
Persistent data values are stored on the device and preserved between launches of the app. The values are merged with any dictionary passed to a tracking call.
The persistentData().add()
method stores persistent data, as shown in the following example:
tealium?.persistentData()?.add(data: ["KEY":"VALUE"])
To clear data for specific keys use the persistentData.deleteData()
method, or to delete all data use the persistentData.deleteAllData()
method.
The following example demonstrates these methods:
class TealiumHelper {
var tealium: Tealium?
// ...
// Adds persistent data to be sent on each hit until manually cleared
// - Parameter data: `[String: Any]` containing key-value pairs to be stored as persistent data
func addPersistentData(_ data: [String: Any]) {
self.tealium?.persistentData()?.add(data)
}
// Deletes persistent data for specific keys
// - Parameter keys: `[String]` containing keys to be deleted
func deleteData(for keys: [String]) {
// clear data for specific keys
self.tealium?.persistentData.deleteData(forKeys: keys)
self.tealium?.persistentData.deleteAllData()
}
}
Volatile Data
Volatile data values are merged into to each event, but discarded upon closing the app and restarting. The values are merged with any dictionary passed to a tracking call.
The volatileData().add()
method stores volatile data.
To clear data for specific keys use the voltileData.deleteData()
method, or to delete all data use the volatileData.deleteAllData()
method.
The following example demonstrates these methods:
class TealiumHelper {
var tealium: Tealium?
// ...
// Adds volatile data to be sent on each hit until the app is terminated
// - Parameter data: `[String: Any]` containing key-value pairs to be stored as volatile data
func addVolatileData(_ data: [String: Any]) {
self.tealium?.volatileData()?.add(data)
}
// Deletes volatile data for specific keys
// - Parameter keys: `[String]` containing keys to be deleted
func deleteData(for keys: [String]) {
// clear data for specific keys
self.tealium?.volatileData.deleteData(forKeys: keys)
self.tealium?.volatileData.deleteAllData()
}
}
This page was last updated: January 7, 2023