Track Events

All non-view activity should be tracked as an event. This is easily done by calling trackEvent() with two parameters: a data object and the instance name.

tealium.trackEvent({"tealium_event":"cart_add"}, "main");

Persist Data

Some variables are required on every event. To save having to manually add this data to every event, the Cordova plugin provides the option to store data as either “volatile” (deleted at app termination) or “persistent” (stored permanently until manually deleted). Once data is stored, it will be appended to every event, including lifecycle event.

These methods will return null on the JavaScript side if the requested data could not be found

The returned value could be any of the supported data types listed above. You should therefore add a safety check to ensure that the returned data is of the expected data type before performing any operations on it (e.g. check that a value expected as an array is really an array before trying to use the Array.push prototype method).

Example:

tealium.getVolatile("myvolatilevariable", window.tealium_instance, 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());
}
});