• Platforms
  • Partners
  • Forums
  • 日本語
  • TLC Tealium Learning Center Tealium Learning
    Community
  • Discussions & Ideas Dicussions & Ideas
  • Product Guides Product Guides
  • Knowledge Base Knowledge Base
  • Developer Docs Developer Docs
  • Education Education
  • TLC Blog TLC Blog
  • Support Desk Support Desk
  • CDH Customer Data Hub Customer Data Hub
  • Mobile
  • Getting Started
    • Overview
    • Quick Start Guide
    • Mobile Concepts
    • Client-Side
    • Server-Side
    • Tracking Webviews
    • Data Layer
    • Consent Management
    • Event Batching
    • User Location and Geofencing
    • Media Tracking
    • Deep Links
    • Timed Events
    • Trace
    • Hosted Data Layer
    • Adobe Visitor Service Module
    • Feature Comparison
    • Troubleshooting
  • Remote Commands
    • Overview
    • How It Works
    • Integrations
      • Adjust
      • AppsFlyer
      • Branch
      • Braze
      • Contentsquare
      • Facebook
      • Firebase
      • Kochava
      • Usabilla
  • Android (Java)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Module
      • Optimizely X Tracking Module
    • Android TV
    • Android Wear
    • API Reference
      • ConsentManager
      • DataSources
      • Lifecycle
      • Tealium
      • Tealium.Config
      • TealiumLocation
    • Release Notes
  • Android (Kotlin)
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • Identity Resolution
    • Module List
      • Ad Identifier Module
      • AutoTracking Module
      • AdobeVisitorService Module
      • Collect Module
      • Collectors Module
      • Crash Reporter Module
      • In-App Purchase Module
      • Install Referrer Module
      • Lifecycle Tracking Module
      • Location Manager Module
      • Media Module
      • RemoteCommands Module
      • Tag Management Dispatcher Module
      • Visitor Service Module
    • Android TV
    • API Reference
      • ConsentCategory
      • ConsentManager
      • CurrentVisit
      • DataLayer
      • Lifecycle
      • LocationManager
      • Media
      • Tealium
      • TealiumConfig
      • VisitorProfile
      • VisitorService
    • Release Notes
  • Cordova 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Module List
      • Ad Identifier Module
      • Crash Reporter Module
      • Install Referrer Module
    • API Reference
    • Release Notes
  • Cordova 2.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Flutter 1.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
    • Release Notes
  • Flutter 2.x
    • Overview
    • Install
    • Track
    • Consent Management
    • Data Management
    • API Reference
      • Tealium
      • TealiumConfig
      • VisitorProfile
    • Release Notes
  • iOS (Objective-C)
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • Consent Management
    • Tag Management
    • Module List
      • Lifecycle Tracking Module
    • tvOS
    • watchOS
    • API Reference
    • Release Notes
  • iOS (Swift) 1.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Data Management
    • App Extensions
    • Identity Resolution
    • Consent Management
    • Modules
    • Module List
      • AppData Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DataSource Module
      • DefaultStorage Module
      • Delegate Module
      • DeviceData Module
      • DispatchQueue Module
      • FileStorage Module
      • Lifecycle Module
      • Location Module
      • Logger Module
      • PersistentData Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
      • VolatileData Module
    • Feature Comparison
    • Working with Objective-C
    • API Reference
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManagerDelegate
      • TealiumConsentManager
      • TealiumInstanceManager
      • TealiumPersistentData
      • TealiumVolatileData
      • Tealium
    • Release Notes
  • iOS (Swift) 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • App Extensions
    • Identity Resolution
    • Modules
    • Module List
      • AppData Module
      • AdobeVisitorService Module
      • Attribution Module
      • AutoTracking Module
      • Collect Module
      • Connectivity Module
      • CrashReporter Module
      • DeviceData Module
      • In-App Purchase Module
      • Lifecycle Module
      • Location Module
      • Media Module
      • RemoteCommands Module
      • TagManagement Module
      • VisitorService Module
    • Working with Objective-C
    • API Reference
      • LocationModule
      • MediaSession
      • Tealium
      • TealiumConfig
      • TealiumConsentCategories
      • TealiumConsentManager
      • TealiumDataLayer
      • TealiumInstanceManager
    • Release Notes
  • NativeScript
    • Overview
    • Install
    • Track
    • API Reference
      • Tealium
      • TealiumConfig
    • Release Notes
  • React Native 1.x
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • React Native 2.x
    • Overview
    • Install
    • Track
    • Location Module
    • API Reference
    • Release Notes
  • Unity 1.x
    • Overview
    • Install
    • Track
    • API Reference
  • Unity 2.x
    • Overview
    • Install
    • Track
    • API Reference
  • Xamarin 1.x
    • Overview
    • Install
    • Track
    • Data Management
    • Consent Management
    • API Reference
    • Release Notes
  • Xamarin 2.x
    • Overview
    • Install
    • Track
    • Data Layer
    • Consent Management
    • API Reference
    • Release Notes
  • Web
  • Getting Started
    • Overview
    • Quick Start Guide
    • Web Concepts
    • Data Layer
      • An Introduction to the Data Layer
      • How the Data Layer Works for Websites
      • Data Layer Best Practices
      • Definitions
        • Retail
        • Publisher
        • Hotel
        • Travel
        • Basic Video Tracking
  • Adobe Launch
    • Overview
    • Install
    • Data Layer
  • AMP
    • Overview
    • Install
    • Track
    • Data Layer
  • Angular
    • Overview
    • Install
    • Track
    • API Reference
  • Google Tag Manager
    • Overview
    • Install
    • Data Layer
  • JavaScript (Web)
    • Overview
    • Install
    • Track
    • Data Layer
    • Universal Data Object (utag_data)
    • Universal Tag (utag.js)
    • Data Layer Object (b)
    • Single-Page Applications
    • Settings
    • Debugging
    • API Reference
      • Cookie Functions
      • GDPR Functions
      • Tracking Functions
      • Utility Functions
    • Release Notes
  • Server
  • C#
    • Overview
    • Install
    • Track
    • Data Layer
    • API Reference
    • Release Notes
  • HTTP API
    • Overview
    • Endpoint
    • Data Layer
  • Java
    • Overview
    • Install
    • Track
    • API Reference
    • Release Notes
  • Node
    • Overview
    • Install
    • Track
    • API Reference
  • Python
    • Overview
    • Install
    • Track
    • API Reference
  • Roku
    • Overview
    • Install
    • Track
    • API Reference
  • Ruby
    • Overview
    • Install
    • Track
    • API Reference
REACT NATIVE

API Reference

Reference guide for classes and methods provided by Tealium for React Native.

Class: Tealium

The following summarizes the commonly used methods of the Tealium class for React Native library.

Method Description
addRemoteCommand() Adds a remote command to the remote command manager
addData() Adds data to persistent data layer
getData() Retrieves a specified value from the data layer
getConsentCategories() Retrieves the user’s consented categories
getConsentStatus() Retrieves the user’s consent status
getVisitorId() Retrieves the current Visitor ID
initialize() Initializes Tealium with configuration parameters
joinTrace() Joins a trace with the given ID
leaveTrace() Leaves active trace session
removeData() Remove persistent data that has been previously set using addData()
removeRemoteCommand() Removes a remote command from the remote command manager
setConsentCategories() Sets the consent categories of a user
setConsentExpiryListener() Sets the consent expired listener/callback
setConsentStatus() Sets the consent status of a user
setVisitorServiceListener() Defines the visitor service listener/callback
terminateInstance() Disables and destroys the Tealium instance
track() Track an event or screen view

addRemoteCommand()

Adds a remote command to the remote command manager.

Tealium.addRemoteCommand(id, callback);
Parameters Type Description Example
id String Name of the command ID from the tag configuration "test_command"
callback Function A callback function to execute after the response is received from the remote command. The callback returns a payload of key-value pairs from the tag mappings. (see example)

Example:

Tealium.addRemoteCommand("firebase", payload => {

  var eventName = payload["firebase_event_name"];
  var eventProperties = payload["firebase_event_properties"];

  analytics.logEvent(eventName, eventProperties);
});

addData()

Adds data to the persistent data storage for the given expiration.

Tealium.addData(data, expiry);
Parameters Type Description Example
data Object JSON object of key-value pairs, where keys are strings and the values are either a string or array of strings {"persistent_key2" : "persistent_val2"}
expiry Expiry Length of time for which to persist the data Expiry.forever

Collectors

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.

Collector Name TealiumConfig Reference
AppData* Collectors.AppData
Connectivity* Collectors.Connectivity
Device Collectors.Device
Lifecycle Collectors.Lifecycle
VisitorService Collectors.VisitorService

These modules are enabled or disabled using the TealiumConfig collectors property as described below

ConsentExpiry

Defines the consent preferences expiration

Parameters Type Description Example
time Number The amount of time before expiration 90
unit TimeUnit The unit of time before expiration TimeUnit.days

Example:

ConsentExpiry(90, TimeUnit.days)

TimeUnit

Value Description
.minutes Minutes
.hours Hours
.months Months
.days Days

ConsentPolicy

Defines the consent policy to adhere to. If no consent policy is defined on the TealiumConfig object, the consent manager will be disabled.

Example:

ConsentPolicy.gdpr

Value Description
.gdpr GDPR
.ccpa CCPA

Dispatchers

Dispatchers are modules that send the data from your data layer and send it to a Tealium endpoint. The following dispatchers are currently available:

Dispatcher Name TealiumConfig Reference
Collect Dispatchers.Collect
RemoteCommands Dispatchers.RemoteCommands
TagManagement Dispatchers.TagManagement

At least one dispatcher is required. If no dispatchers are specified, your data is not sent anywhere.

Expiry

Defines the custom data expiration

Example:

Expiry.session

Parameters Type Description Example
time Number The amount of time before expiration 90
unit TimeUnit The unit of time before expiration TimeUnit.days

Example:

ConsentExpiry(90, TimeUnit.days)

TimeUnit

Value Description
.minutes Minutes
.hours Hours
.months Months
.days Days

getData()

Retrieves the value for a specified key in the persistent data layer, then returns in the form of a callback function.

Tealium.getData(key, callback);
Parameters Type Description Example
key String Key to retrieve from the data layer (see example)
callback Function Callback function to use the retrieved value for key (see example)

Example:

Tealium.getData('test_session_key', value => {
   console.log("Value: " + value)
});

getConsentCategories()

Retrieves the user’s consented categories.

Tealium.getConsentCategories(callback);
Parameters Type Description Example
callback Function Callback function to use the consent categories (see example)

Example:

Tealium.getConsentCategories(categories => {
    console.log("Consent Categories: " + categories)
});

getConsentStatus()

Retrieves the user consent status and returns in the form of a callback function.

Tealium.getConsentStatus(callback);
Parameters Type Description Example
callback Function Callback function to use the consent status (see example)

Example:

Tealium.getConsentStatus(status => {
    console.log("Consent Status: " + status)
});

getVisitorId()

Retrieves the user’s visitor ID and returns in the form of a callback function.

Tealium.getVisitorId(callback);
Parameters Type Description Example
callback Function Callback function to use the Visitor ID (see example)

Example:

Tealium.getVisitorId(value => {
    console.log("Visitor ID: " + value)
});

initialize()

Initialize Tealium before calling any other method.

Tealium.initialize(config);
Parameters Type Description Example
config TealiumConfig Tealium configuration parameters (see example)
callback Function (Optional) Callback function after the Tealium instance is ready (see example)

Example:

let config: TealiumConfig =
{
	account: 'tealiummobile',
	profile: 'demo',
	environment: TealiumEnvironment.dev,
	dispatchers: [Dispatchers.Collect,
	 			  Dispatchers.TagManagement,
	  			  Dispatchers.RemoteCommands],
	collectors: [Collectors.AppData,
				 Collectors.DeviceData,
				 Collectors.Lifecycle,
				 Collectors.Connectivity],
	consentLoggingEnabled: true,
	consentPolicy: ConsentPolicy.gdpr,
	visitorServiceEnabled: true
};

Tealium.initialize(config, success => {
    if (!success) {
        // error creating instance.
    }
    // do something on-ready
});

joinTrace()

Joins a trace with the specified ID. Learn more about the Trace feature in the Tealium Customer Data Hub.

Tealium.joinTrace(id);
Parameters Type Description Example
id String Trace ID retrieved from the CDH abc123xy

leaveTrace()

A trace remains active for the duration of the app session until the leaveTrace() method is called, which leaves a previously joined trace and ends the visitor session.

Tealium.leaveTrace();

LogLevel

Sets the log level property, which controls how much information is logged, to one of the following values:

Value Description
.dev Informational events that highlight the progress of the application
.qa Debug-level events used for debugging an application
.prod Error events such as critical errors and failures
.silent No Logging (default)

Example:

LogLevel.dev

setConsentCategories()

Sets the consent categories of a user. Pass in an array of Strings to set the categories. Default is an empty array until ConsentStatus is set to .consented. If the consent status is .consented and no categories are specified with the setConsentCategories() method, then all categories are set.

Tealium.setConsentCategories(categories);
Parameters Type Description Example
categories ConsentCategories[] Array of user consent categories [ConsentCategories.email, ConsentCategories.personalization]

Example:

Tealium.setConsentCategories([ConsentCategories.analytics, ConsentCategories.email]);

ConsentCategories

Value Description
analytics Analytics
affiliates Affiliates
displayAds Display Ads
email Email
personalization Personalization
search Search
social Social
bigData Big Data
mobile Mobile
engagement Engagement
monitoring Monitoring
crm CRM
cdp CDP
cookieMatch Cookie Match
misc Misc

setConsentExpiryListener()

Defines a callback to execute after the user’s consent preferences have expired according the ConsentExpiry.

Tealium.setConsentExpiryListener(callback);
Parameters Type Description Example
callback Function Code to execute after consent expires (see example)

Example:

Tealium.setConsentExpiryListener(() => {
    console.log("Consent Expired");
});

setConsentStatus()

Sets the consent status of a user. Default is .unknown until changed.

Tealium.setConsentStatus(status);
Parameters Type Description Example
status ConsentStatus User consent status ConsentStatus.consented

Example:

Tealium.setConsentStatus(ConsentStatus.consented);

ConsentStatus

Value Description
.consented Consented
.notConsented Not Consented
.unknown Unknown

setVisitorServiceListener()

Defines a callback to execute when the visitor profile has been updated. The updated VisitorProfile is provided in the callback response.

The VisitorService module implements the Data Layer Enrichment feature of the Tealium Customer Data Hub.

Usage of this module is recommended if you are licensed for Tealium AudienceStream and you want to use the visitor profile to enhance the user experience in your mobile application. If you are not licensed for AudienceStream, usage of this module is not recommended as no visitor profile is returned.

Tealium.setVisitorServiceListener(callback);
Parameters Type Description Example
callback Function Code to execute after the updated visitor profile is returned (see example)

Example:

Tealium.setVisitorServiceListener(profile => {
    console.log(JSON.stringify(profile["audiences"]));
});

removeData()

Remove persistent data that has been previously set using Tealium.setPersistentData().

Tealium.removeData(keys);
Parameters Type Description Example
keys String[] Array of key names ["foo", "bar"]

removeRemoteCommand()

Removes a remote command from the remote command manager.

Tealium.removeRemoteCommand(id);
Parameters Type Description Example
id String Name of the command ID to remove "test_command"

Example:

Tealium.removeRemoteCommand("firebase");

TealiumEnvironment

The environment is one of three default environments (Dev, QA, Prod) or any custom environments that Tealium publishes to. Select one of these environments.

Example:

TealiumEnvironment.dev

Value Description
.dev Development
.qa QA/UAT
.prod Production

TealiumConfig

The following summarizes the properties of the TealiumConfig class.

Parameters Type Description Example
account String (Required) Tealium account name "companyXYZ"
profile String (Required) Tealium profile name "main"
environment TealiumEnvironment (Required) Tealium environment name "TealiumEnvironment.dev"
dataSource String CDH data source key "abc123"
collectors Collectors[] (Required) Sets the list of Collectors to initialize the Tealium library with [Collectors.AppData]
dispatchers Dispatchers[] (Required) Sets the list of Dispatchers to initialize the Tealium library with [Dispatchers.Collect]
customVisitorId String Sets a custom Visitor ID ALK2398LSDKJ3289SLKJ3298SLKJ3
memoryReportingEnabled Boolean Enables or disables memory reporting in the DeviceData module (default: disabled). true
overrideCollectURL String Overrides the Tealium Collect URL to send data to a different endpoint. If using the event batching feature, also override the overrideCollectBatchURL property. https://custom-domain.com/event
overrideCollectBatchURL String Overrides the Tealium Collect batch URL to send data to a different endpoint. https://custom-domain.com/batch-event
overrideLibrarySettingsURL String Overrides the publish settings URL. https://custom-domain.com/mobile.html
overrideTagManagementURL String Overrides the default URL used by the Tag Management module. This is needed if you are self-hosting your Tealium JavaScript files. https://custom-domain.com/path/env/utag.js
deepLinkTrackingEnabled Boolean Enables or disables automatic tracking of standard deep links, such as links to the app from Facebook or other sources, as well as QR trace. (default: enabled) false
qrTraceEnabled Boolean Enables or disables QR trace. (default: enabled) false
loglevel LogLevel Sets the log level property, which controls how much information is logged (default: silent) LogLevel.dev
consentExpiry ConsentExpiry Sets the expiration of the user’s consent preferences. (defaults dependent upon policy) ConsentExpiry(90, TimeUnit.days)
consentLoggingEnabled Boolean Enables the Consent Logging feature, which sends all consent status changes to Tealium Customer Data Hub for auditing purposes. (default: enabled) true
consentPolicy ConsentPolicy Sets the consent policy. e.g. CCPA or GDPR. Consent Manager is only enabled if this property is set. ConsentPolicy.gdpr
lifecycleAutotrackingEnabled Boolean Enables or disables lifecycle auto tracking. (default: enabled) false
useRemoteLibrarySettings Boolean Enables or disables the Mobile Publish Settings (default: enabled) Configure the Mobile Publish Settings in Tealium iQ Tag Management, or disable the feature. false
visitorServiceEnabled Boolean Enables or disables the automatic retrieval of the Visitor Profile using the Data Layer Enrichment API (default: disabled) true
remoteCommands RemoteCommand[] Sets a list of RemoteCommand objects to add when the instance is ready [{ id: "hello-world", callback: (payload) => { console.log("hello-world: " + JSON.stringify(payload)); } }]

TealiumDispatch

An interface that defines the type of dispatch to be tracked.

TealiumView

To track screen views, pass an instance of TealiumView(viewName, data) to the track() method. TealiumView is comprised of a view name, which appears in the tracking call as tealium_event, and an optional data dictionary.

The following is an example:

let tealView = TealiumView("VIEW_NAME", {"key": "value"})
Tealium.track(tealView)

TealiumEvent

To track non-view events, pass an instance of TealiumEvent(eventName, data) to the track() method. TealiumEvent is comprised of an event name, which appears in the tracking call as tealium_event, and an optional data dictionary.

The following is an example:

let tealEvent = TealiumEvent("EVENT_NAME", {"key": "value"})
Tealium.track(tealEvent)

terminateIntance()

Disables the Tealium library and removes all module references. Re-enable by creating a new Tealium instance if required.

Tealium.terminateIntance();

track()

Track an event with either a TealiumEvent or TealiumView dispatch.

Tealium.track(dispatch);

Parameters Type Description Example
dispatch TealiumDispatch Tealium dispatch with the event name and data layer TealiumEvent("button_click", { "button_name": "Submit" })

VisitorProfile

The visitor profile is an object that contains friendly names for each attribute. There is a currentVisit property that allows you to distinguish visitor/visit attribute types. Access each attribute value by ID using a subscript. If the attribute does not exist, null is returned. See the below list for examples.

Attribute Types

Parameters Properties Value
arraysOfBooleans id: String, value: Boolean[] id: "5129", value: [true,false,true,true]
arraysOfNumbers id: String, value: Number[] id: "57", value: [4.82125, 16.8, 0.5714285714285714]
arraysOfStrings id: String, value: String[] id: "5213", value: ["green shirts", "green shirts", "blue shirts"]
audiences id: String, value: String id: "tealiummobile\_demo\_103", value: "iOS Users"
badges id: String, value: Boolean id: "2815", value: true
booleans id: String, value: Boolean id: "4868", value: true
currentVisit All attributes for current visit visitorProfile. The current visit profile does not contain Audiences or Badges. TealiumCurrentVisitProfile(dates: ["5376": 1567536668080, "10": 1567536668000], booleans: ["4530": true], numbers: ["32": 3.8])
dates id: String, value: Number id: "22", value: 1567120112000
numbers id: String, value: Number id: "5728", value: 4.82125
setOfStrings id: String, value: Set(String) id: "5211", value: ["green shirts", "red shirts", "blue shirts"]
strings id: String, value: String id: "5380", value: "green shirts"
tallies id: String, value: Object "57": [["category 1": 2.0], "category 2": 1.0]]
tallyValue id: String, value: Number ["category 1": 2.0]

RemoteCommand

An interface that defines a configured Remote Command

Value Description
id The unique identifier name for the RemoteCommand
path (Optional) local file to use for mappings
url (Optional) remote file to use for mappings
callback (Optional) callback function for the RemoteCommand

The path and URL are optional, but either provide only one or the other, or omit both in the case where the mappings are handled by a tag in Tealium iQ Tag Management.

Provide the callback if the command is to be handled within the scope of your React Native app. Omit the callback if the handler has already been registered natively.

The following example is a local mappings file for a command handled by Javascript:

let localCommand: RemoteCommand = {
    id: "hello-world",
    path: "hello-mappings.json",
    callback: (payload) => {
        //...
    }
}

The following example is a remote mappings file for a command handled natively:

let remoteNativeCommand: RemoteCommand = {
    id: "hello-world",
    url: "https://you.domain.com/hello-mappings.json"
}
"Release Notes "
Previous
Release Notes

 

Was this article helpful?

This page was last updated: March 16, 2022      

Thank you for your feedback!

Table of Contents

  • Class: Tealium
    • addRemoteCommand()
    • addData()
    • Collectors
    • ConsentExpiry
    • ConsentPolicy
    • Dispatchers
    • Expiry
    • getData()
    • getConsentCategories()
    • getConsentStatus()
    • getVisitorId()
    • initialize()
    • joinTrace()
    • leaveTrace()
    • LogLevel
    • setConsentCategories()
    • setConsentExpiryListener()
    • setConsentStatus()
    • setVisitorServiceListener()
    • removeData()
    • removeRemoteCommand()
    • TealiumEnvironment
    • TealiumConfig
    • TealiumDispatch
    • terminateIntance()
    • track()
    • VisitorProfile
    • RemoteCommand
  • Platforms
  • Partners
  • Forums
  • Mobile
  • Getting Started
  • Remote Commands
  • Android (Java)
  • Android (Kotlin)
  • Cordova 1.x
  • Cordova 2.x
  • Flutter 1.x
  • Flutter 2.x
  • iOS (Objective-C)
  • iOS (Swift) 1.x
  • iOS (Swift) 2.x
  • NativeScript
  • React Native 1.x
  • React Native 2.x
  • Unity 1.x
  • Unity 2.x
  • Xamarin 1.x
  • Xamarin 2.x
  • Web
  • Getting Started
  • Adobe Launch
  • AMP
  • Angular
  • Google Tag Manager
  • JavaScript (Web)
  • Server
  • C#
  • HTTP API
  • Java
  • Node
  • Python
  • Roku
  • Ruby