Track
Learn about the methods for tracking user activity.
Track Views
Track views with the track()
method, as shown in the following examples:
// Set event attributes
Udo data = new Udo();
data.put("KEY", "VALUE");
// With optional callback
DispatchCallBack callback = new DispatchCallBack() {
public void dispatchComplete(boolean success, String encodedURLString, String error){
// Callback handling
System.out.println("Dispatch successful: " + String.valueOf(success));
}
}
tealium.track("EVENT_NAME", data, callback);
The following example tracks a page view:
tealium.track("SCREEN_VIEW", data, callback);
The data and callback arguments are optional.
Track Events
Track events with the same track()
method used to track views, as shown in the following example:
// Set event attributes
Udo data = new Udo();
data.put("KEY", "VALUE");
// With optional callback
DispatchCallBack callback = new DispatchCallBack() {
public void dispatchComplete(boolean success, String encodedURLString, String error){
// Callback handling
System.out.println("Dispatch successful: " + String.valueOf(success));
}
}
tealium.track("EVENT_NAME", data, callback);
The following example tracks a user login:
// Event attributes
Udo data = new Udo();
data.put("user_id", "0123456789");
data.put("email_address", "user@example.com");
// With optional callback
DispatchCallBack callBack = new DispatchCallBack(){
public void dispatchComplete(boolean success, String error) {
// Callback handling
}
}
tealium.track("user_login", data, callback);
The data and callback arguments are optional.
This page was last updated: January 7, 2023