Track
Learn about the methods for tracking user activity.
Track Views
The trackView()
method tracks a screen view with associated data and, optionally, triggers a callback function.
let mydata = ["KEY": "VALUE"]
// track call with type specified and completion block
tealium?.trackView(title: "EVENT_NAME",
data: mydata,
completion: { (success: Bool, info: [String: Any]?, error: Error?) in
//...
})
The value passed to title
will appear in the data layer as the variable tealium_event
.
Track Events
The track()
method tracks an event with associated data and, optionally, triggers a callback function.
let mydata = ["KEY": "VALUE"]
// track call with type specified and completion block
tealium?.track(title: "EVENT_NAME",
data: mydata,
completion: { (success: Bool, info: [String: Any]?, error: Error?) in
//...
})
The value passed to title
will appear in the data layer as the variable tealium_event
.
Trace
Join Trace
The joinTrace()
method joins a trace with the specified ID. Learn more about the Trace feature in the Tealium Customer Data Hub.
class TealiumHelper {
var tealium: Tealium?
// ...
func joinTrace(traceId id: String) {
tealium?.joinTrace(traceId: "TRACE_ID")
// ...
}
}
Leave trace
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.
class TealiumHelper {
var tealium: Tealium?
// ...
func leaveTrace() {
tealium?.leaveTrace()
// ...
}
}
Connector actions set to run at “End of Visit” does not run until the session expires.
To preserve the trace visitor session when leaving the trace, pass the optional argument false
, as shown in the following example:
tealium?.leaveTrace(killVisitorSession: false)
This page was last updated: May 9, 2024