Track
Learn about the methods for tracking user activity.
Track Views
To track screen views, pass an instance of TealiumView(viewName:dataLayer:)
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:
val tealView = TealiumView("VIEW_NAME", mutableMapOf("key" to "value"))
tealium.track(tealView);
Track Events
To track non-view events, pass an instance of TealiumEvent(eventName:dataLayer:)
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:
val tealEvent = TealiumEvent("EVENT_NAME", mutableMapOf("key" to "value"))
tealium.track(tealEvent);
Timed Events
Timed events measure the duration of an event or the duration between two events. Timed events are triggered automatically or manually.
Automatic Triggers
Automatically track the duration between events by setting timedEventTriggers
to a list of EventTrigger
objects, specifying the names of the start and stop events.
The following is an example of tracking a timed event with an automatic trigger:
timedEventTriggers = mutableListOf(EventTrigger.forEventName(
"cart_add",
"purchase"))
Manual Triggers
Manually track the duration of an event by starting and stopping the timed event based on your custom logic.
Start tracking the duration of an event with startTimedEvent()
.
tealium.startTimedEvent(name: "TimeSpentViewingProduct")
Stop a timed event with stopTimedEvent()
:
tealium.stopTimedEvent(name: "TimeSpentViewingProduct")
Cancel a previously started timed event with cancelTimedEvent()
:
tealium.cancelTimedEvent(name: "TimeSpentViewingProduct")
Trace
Join Trace
Join a trace with the specified ID by calling joinTrace()
. Learn more about the Trace feature in the Tealium Customer Data Hub.
Tealium["INSTANCE_NAME"]?.joinTrace("TRACE_ID")
Leave trace
A trace remains active for the duration of the app session until you call leaveTrace()
, which leaves a previously joined trace and ends the visitor session.
Tealium["INSTANCE_NAME"]?.leaveTrace()
End the visitor session remotely with endTraceVisitorSession()
, which does not terminate the SDK session or reset the session ID.
Tealium["INSTANCE_NAME"]?.endTraceVisitorSession()
This page was last updated: January 7, 2023