• 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
ANDROID KOTLIN

Tealium

Reference guide for Tealium class and methods provided by Tealium for Android (Kotlin).

Class: Tealium

The Tealium class provides methods for tracking screen views and events. The following document summarizes the commonly used methods and properties of the Tealium class for Kotlin. Individual modules may also provide their own extensions for the Tealium class if they are enabled.

Method/Property Description
cancelTimedEvent() Cancels the timer for a timed event.
consentManager Access to the Consent Manager in order to set the user consent preferences.
dataLayer Access to persistent storage on the device - items within the data layer are added to each event.
endTraceVisitorSession() Ends the visitor session remotely to test end of session events.
events Allows you to provide listener classes to a numerous events throughout the Tealium SDK.
joinTrace() Adds the supplied trace ID to the data layer for the current session.
leaveTrace() Leaves the trace by removing the trace ID.
linkEcidToKnownIdentifier Links the current ECID to a known secondary ID.
modules Provides access to the modules within the system.
resetVisitor() Resets the visitor ECID by retrieving a new one on the next tracking call.
sendQueuedDispatches() Requests that any DispatchValidators be re-evaluated.
session Provides information relating to the current session.
startTimedEvent() Starts a timed event with the given name.
stopTimedEvent() Stops the timer for a timed event which triggers the timed_event tracking call.
Tealium Constructor method that creates a Tealium instance.
track() Method for tracking your Screen views or events.
visitor Returns the full AdobeVisitor instance.
visitorId The current Visitor ID that is stored in the data layer.

cancelTimedEvent()

Cancels a previously started timed event. The timed event is not tracked.

tealium.cancelTimedEvent(name: "TIMED_EVENT_NAME")
Parameters Type Description
name String The name of the timed event

consentManager

Allows you to set your current consent status and categories, and see the current policy enforced. Learn more in the Consent Management guide.

tealium.consentManager.userConsentStatus = ConsentStatus.CONSENTED

dataLayer

Provides persistent storage on the device for key-value pairs, while also allowing you to set expiry times. Each entry is also added to every dispatch that you send through the track() method. Learn more in the Data Management guide.

tealium.dataLayer.putString("key", "value", Expiry.FOREVER)

endTraceVisitorSession()

Ends the visitor session remotely. Does not terminate the SDK session or reset the session ID.

Tealium["INSTANCE_NAME"]?.endTraceVisitorSession()

events

Provides listener classes to your Tealium instance in order to receive useful information from the SDK.

The following example registers a listener for any consent preference changes. This listener is provided with the new consent preferences and the current policy enforced. Additional listeners available at com.tealium.core.messaging.

tealium.events.subscribe(object: UserConsentPreferencesUpdatedListener {
    override fun onUserConsentPreferencesUpdated(userConsentPreferences: UserConsentPreferences, policy: ConsentManagementPolicy) {
        // take action on consent changes
    }
})

joinTrace()

Adds the supplied trace ID to the data layer for the current session.

Tealium["INSTANCE_NAME"]?.joinTrace(traceId)
Parameters Type Description
traceId String Trace ID

leaveTrace()

Leaves the trace by removing the trace ID.

Tealium["INSTANCE_NAME"]?.leaveTrace()

linkEcidToKnownIdentifier()

Links the current ECID to a known secondary identifier, such as an email address or other internal ID.

linkEcidToKnownIdentifier(
  knownId: String,
  adobeDataProviderId: String,
  authState: Int?,
  adobeResponseListener: ResponseListener<AdobeVisitor>?
  )
Parameters Type Description
knownId String The known identifier.
adobeDataProviderId String The Adobe data provider identifier.
authState Int The authenticated state.
adobeResponseListener ResponseListener<AdobeVisitor> The Adobe response listener.

Example:

var tealium: Tealium?
...

tealium.adobeVisitorApi?.linkEcidToKnownIdentifier(
  "myidentifier",
  "123456",
  AdobeAuthState.AUTH_STATE_AUTHENTICATED,
  null
  )

modules

Provides access to the Module Manager for the SDK, and used to provide access to specific modules.

tealium.modules.getModule(VisitorService::class.java)?.delegate = myDelegate

resetVisitor()

Resets the visitor ECID by retrieving a new one on the next tracking call.

resetVisitor()

Example:

var tealium: Tealium?
//...
tealium?.adobeVisitorApi?.resetVisitor()

sendQueuedDispatches()

Dispatches are queued for a number of reasons by any DispatchValidator. You may request that they be re-evaluated using this method which ignores the event batching restrictions, but adheres to other DispatchValidators. For example, if there was no connectivity and there is still no connectivity then queued dispatches remain queued.

tealium.sendQueuedDispatches()

session

Contains all data relating to the current Session.

val sessionId = tealium.session.id

startTimedEvent()

Starts a timed event with the given name. If this method is called again with the same event name, it is ignored if the event has not been ended or canceled. The event start time is not persisted.

If optional data is passed along with the event name, it is added to the track call when the timer is stopped with the stopTimedEvent() call.

tealium.startTimedEvent(name: "TIMED_EVENT_NAME", mapOf("custom_value" to "custom_key"))
Parameters Type Description
name String The name of the timed event
mapOf("custom_key" to "custom_value") Map (Optional) An object of key-value pair data to be tracked in the data layer

stopTimedEvent()

Stops the timer for a timed event which triggers the timed_event tracking call.

tealium.stopTimedEvent(name: "TIMED_EVENT_NAME")
Parameters Type Description
name String The name of the timed event

Tealium

Constructor method that creates a Tealium instance.

val config = TealiumConfig(key, config);
Parameters Type Description Example
key String New Tealium instance name "abc123"
config Tealium.Config The configuration for the new instance tealConfigObj
// Assuming execution is within Application.onCreate()
val config = TealiumConfig(this, "ACCOUNT_NAME", "PROFILE_NAME", Environment.PROD)
val tealium = Tealium.create("main", config)

Modules are initialized on a background Thread and therefore may not be ready directly after creation of the Tealium object. Add a completion block in order to add any subsequent required configuration as soon as the instance is ready:

val tealium = Tealium.create("main", config) {
    events.subscribe(object : VisitorUpdatedListener {
        override fun onVisitorUpdated(visitorProfile: VisitorProfile) {
            Logger.dev("--", "VisitorProfile updated: $visitorProfile")
        }
    })
}

track()

The method used for tracking events within the system such as screen views and events.

tealium.track(TealiumView("SCREEN_NAME", mapOf("key" to "context value")))

visitor

Returns the full AdobeVisitor instance.

var tealium: Tealium?
//...
val visitor = tealium.adobeVisitorApi?.visitor?.let { visitor ->
    val ecid = visitor.experienceCloudId
    val nextRefresh = visitor.nextRefresh
    val blob = visitor.blob
    val region = visitor.region
    val idSyncTTL = visitor.idSyncTTL
}

visitorId

The current String for the Visitor ID. It is stored within the data layer, and may be overridden if required.

val visitorId = tealium.visitorId
"Media "
Previous
Media
Next
TealiumConfig
"TealiumConfig"

 

Was this article helpful?

This page was last updated: November 9, 2021      

Thank you for your feedback!

Table of Contents

  • Class: Tealium
    • cancelTimedEvent()
    • consentManager
    • dataLayer
    • endTraceVisitorSession()
    • events
    • joinTrace()
    • leaveTrace()
    • linkEcidToKnownIdentifier()
    • modules
    • resetVisitor()
    • sendQueuedDispatches()
    • session
    • startTimedEvent()
    • stopTimedEvent()
    • Tealium
    • track()
    • visitor
    • visitorId
  • 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