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
The addPersistent()
method adds persistent data, as shown in the following example:
tealium.addPersistent("KEY_NAME", "DATA", "INSTANCE_NAME");
The getPersistent()
method gets persistent data, with a callback, as shown in the following example:
tealium.getPersistent("KEY_NAME", "INSTANCE_NAME", function (val) {
// this callback will be called when the persistent data source has been found
if (val === null) {
// returns null if data was not found
alert("Requested persistent data could not be found");
} else {
alert("Persistent object data returned: " + "mypersistentvariable = " + val.toString());
}});
The removePersistent()
method removes persistent data, as shown in the following example:
tealium.removePersistent("KEY_NAME", "INSTANCE_NAME");
Volatile Data
The addVolatile()
method adds volatile data, as shown in the following example:
tealium.addVolatile("KEY_NAME", "DATA", "INSTANCE_NAME");
The getVolatile()
method gets volatile data, with a callback, as shown in the following example:
tealium.getVolatile("KEY_NAME", "INSTANCE_NAME", function (val) {
// this callback will be called when the volatile data source has been found
if (val === null) {
// returns null if data was not found
alert("Requested volatile data could not be found");
} else {
alert("Volatile object data returned: " + "myvolatilevariable = " + val.toString());
}});
The removeVolatile()
method removes volatile data, as shown in the following example:
tealium.removeVolatile("KEY_NAME", window.tealium_instance);
This page was last updated: January 7, 2023