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. |
gatherTrackData() |
Exposes all track data for data layer and Collectors. |
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
}
})
gatherTrackData()
Retrieves track data from data layer and Collectors.
Tealium["INSTANCE_NAME"]?.gatherTrackData()
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
This page was last updated: January 7, 2023