TealiumDataLayer
Reference guide for DataLayer class and methods provided by Tealium for iOS (Swift).
Class: DataLayer
The following summarizes the commonly used methods and properties of the iOS (Swift) DataLayer
class.
Method/Property | Description |
---|---|
add() |
Adds data to the data layer, based on expiration type. |
all |
Returns all data stored on the data layer. |
allSessionData |
Returns all data stored on the data layer for the active session. |
delete() |
Deletes the specified values from storage. |
deleteAll() |
Deletes all values from storage. |
persistentDataStorage |
Returns all event data stored in persistent storage. |
add()
Adds data to the data layer, based on expiration type. If the expiry
parameter is not provided, the expiration type defaults to .session
.
tealium?.dataLayer.add(key, value, expiry)
Parameter | Type | Description |
---|---|---|
key |
String |
Name of key to be stored |
value |
Any |
Data to be stored |
expiry (optional) |
Expiry |
Data expiration level |
all
Returns all data stored on the data layer.
let data: [String: Any] = tealium?.dataLayer.all
Return Type | Description |
---|---|
[String] |
All data stored on the data layer |
allSessionData
Returns all data stored on the data layer for the active session.
let data: [String: Any] = tealium?.dataLayer.allSessionData
Return Type | Description |
---|---|
[String] |
All data stored on the data layer for the active session |
delete()
Deletes specified value from storage based on a specific key.
tealium?.dataLayer.delete(for key)
Parameter | Type | Description |
---|---|---|
key |
String |
Key of value to delete |
To delete multiple values from storage based on multiple keys:
tealium?.dataLayer.delete(for keys)
Parameter | Type | Description |
---|---|---|
keys |
[String] |
Keys of values to delete |
deleteAll()
Deletes all values from storage.
tealium?.dataLayer.deleteAll()
persistentDataStorage
Returns all event data stored in persistent storage.
let data: Set<DataLayerItem> = tealium?.dataLayer.persistentDataStorage
Return Type | Description |
---|---|
Set<DataLayerItem> |
All event data stored in persistent storage |
This page was last updated: January 7, 2023