• 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
FLUTTER

Tealium

The Tealium class serves as the main API entry point for all modules.

Class: Tealium

The following summarizes the commonly used methods of the Flutter Tealium class.

Method Description
addRemoteCommand() Adds a remote command to the remote command manager
addToDataLayer() Adds data to persistent data layer
deleteFromDataLayer() Deletes a single key-value pair from the data layer that was previously set using addToDataLayer()
getFromDataLayer() Gets the value for a specified key in the persistent data layer
getConsentCategories() Gets the user’s consented categories
getConsentStatus() Gets the user’s consent status
getVisitorId() Gets the user’s visitor ID
initialize() Initializes Tealium with configuration parameters
joinTrace() Joins a trace with the given ID
leaveTrace() Leaves a previously joined traced and ends the visitor session
removeFromDataLayer() Removes a list of persistent data keys-value pairs that was previously set using addToDataLayer()
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 user’s consent status
setVisitorServiceListener() Sets the visitor service listener/callback
terminateInstance() Terminates the Tealium instance by disabling the Tealium library and removing all module references
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 receiving the response 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);
});

addToDataLayer()

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

Tealium.addToDataLayer(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_key' : 'persistent_val'}
expiry Expiry Length of time for which to persist the data Expiry.forever

deleteFromDataLayer()

Deletes a single key-value pair from the data layer that was previously set using addToDataLayer().

Tealium.deleteFromDataLayer(key);
Parameters Type Description Example
key String Key to retrieve from the data layer "key_to_delete"

getFromDataLayer()

Gets the value for a specified key in the persistent data layer as a callback function.

Tealium.getFromDataLayer(key);
Parameter Type Description
key String Key to retrieve from the data layer
N/A Future<dynamic> Future succeeds after value was successfully retrieved from Tealium.dataLayer

Example:

Tealium.getFromDataLayer('key')
    .then((value) => print('Value From data layer: $value')));

getConsentCategories()

Gets the user’s consented categories.

Tealium.getConsentCategories();
Parameter Type Description
N/A Future<List<ConsentCategories>> Future completes after the consent categories have been successfully retrieved from the Tealium.ConsentManager

Example:

Tealium.getConsentCategories()
  .then((categories) =>
      print('Consent Categories: ' + categories.join(","))));

getConsentStatus()

Gets the user’s consent status as a callback function.

Tealium.getConsentStatus(callback);
Parameter Type Description
N/A Future<String> Future completes after the consent status was successfully retrieved from the Tealium.ConsentManager

Example:

Tealium.getConsentStatus()
  .then((status) => print('Consent Status: $status')));

getVisitorId()

Gets the user’s visitor ID as a callback function.

Tealium.getVisitorId();
Parameter Type Description
N/A Future<String> Future returns after the Tealium.visitorId was successfully retrieved

initialize()

Initialize Tealium before calling any other method.

Tealium.initialize(config);
Parameter Type Description
config config Configuration
N/A Future<String> Future returns true if the Tealium initialization is successful, or false if there is an error

Example:

let config: TealiumConfig =
{
	account: 'ACCOUNT',
	profile: 'PROFILE',
	environment: TealiumEnvironment.dev,
	dispatchers: [Dispatchers.Collect,
	 			  Dispatchers.TagManagement,
	  			  Dispatchers.RemoteCommands],
	collectors: [Collectors.AppData,
				 Collectors.DeviceData,
				 Collectors.Lifecycle,
				 Collectors.Connectivity],
    loglevel: LogLevel.DEV,
	consentLoggingEnabled: true,
	consentPolicy: ConsentPolicy.GDPR,
	visitorServiceEnabled: true
};

    Tealium.initialize(config)
      .then((value) => {
          if (value)
            {
              print('Tealium Initialized'),
              Tealium.setConsentStatus(ConsentStatus.consented),
              Tealium.setConsentExpiryListener(
                  () => print('Consent Expired'));
            }
          else
            {
            	print('Tealium Initialization Error')
            }
        });

joinTrace()

Joins a trace with the specified ID. Learn more about Trace.

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

leaveTrace()

Leaves a previously joined traced and ends the visitor session. The trace remains active for the duration of the app session until this method is called.

Tealium.leaveTrace();

removeFromDataLayer()

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

Tealium.removeFromDataLayer(keys);
Parameter Type Description Example
keys List<String> Array of key names ["key1", "key2"]

removeRemoteCommand()

Removes a remote command from the remote command manager.

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

Example:

Tealium.removeRemoteCommand('test_command');

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);
Parameter Type Description Example
categories List<ConsentCategories> Array of user consent categories [ConsentCategories.email, ConsentCategories.personalization]

Example:

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

Consent Categories

The following consent categories are available:

Value Description
anlytics Anlytics
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()

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

Tealium.setConsentExpiryListener(callback);
Parameter Type Description
callback Function Code to execute after consent expires
Tealium.setConsentExpiryListener(() => {
    print('Consent Expired');
});

setConsentStatus()

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

Tealium.setConsentStatus(status);
Parameter Type Description
status status Consent status

Example:

Tealium.setConsentStatus(ConsentStatus.consented);

Consent Status

The following consent statuses are available:

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

setVisitorServiceListener()

Sets a callback to execute when the visitor profile is 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);
Parameter Type Description
callback Function Code to execute after the updated visitor profile returns

Example:

Tealium.setVisitorServiceListener((profile) => {
    print(JsonEncoder().convert(profile));
});

terminateInstance()

Terminates the Tealium instance by disabling the Tealium library and removing 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);
Parameter Type Description Example
dispatch TealiumDispatch Tealium dispatch with the event name and data layer TealiumEvent('button_click', { 'button_name': 'Submit' })
Next
TealiumConfig
"TealiumConfig"

 

Was this article helpful?

This page was last updated: May 13, 2022      

Thank you for your feedback!

Table of Contents

  • Class: Tealium
    • addRemoteCommand()
    • addToDataLayer()
    • deleteFromDataLayer()
    • getFromDataLayer()
    • getConsentCategories()
    • getConsentStatus()
    • getVisitorId()
    • initialize()
    • joinTrace()
    • leaveTrace()
    • removeFromDataLayer()
    • removeRemoteCommand()
    • setConsentCategories()
    • setConsentExpiryListener()
    • setConsentStatus()
    • setVisitorServiceListener()
    • terminateInstance()
    • track()
  • 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