The online Trailblazer Community is now read-only. [Read the FAQ] [Get Help]
Time tracking captures user engagement metrics by monitoring active time spent on pages and catalog items. Events are sent when configurable time thresholds are crossed (for example, 30 seconds or 60 seconds of active engagement).
Time tracking attaches itself to other events you send (such as catalog events) and automatically includes their context in engagement events. Only active time is tracked—periods when the user is actually interacting with the page through mouse movement, clicks, scrolling, or keyboard input.
By default, time tracking is disabled. To enable it, set enabled: true in your configuration. To disable it, set enabled: false or remove the time tracking configuration.
| Option Name | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Set to true to enable time tracking. |
thresholds | array | See below | Array of threshold objects with label (string) and threshold (milliseconds). |
eventTypes | array | ['catalog'] | Event types to capture context from. Only the first matching event is captured. |
activityTimeoutMillis | number | 5000 | Milliseconds of inactivity before user is considered inactive (minimum: 1000ms). |
minimumActivityTimeToRegister | number | 300 | Minimum milliseconds of activity required to count as active time. |
maxSessionDurationMillis | number | 3600000 | Maximum session duration in milliseconds (1 hour). Session resets after this time. |
sendPageExitWithoutThreshold | boolean | false | If true, send pageExit event even when no threshold was reached. |
maxEventsPerSession | number | 20 | Maximum time tracking events per session. Prevents event flooding. |
Default thresholds: [{label: 'LOW_INTEREST', threshold: 30000}, {label: 'HIGH_INTEREST', threshold: 60000}]
Time tracking captures context from other events you send. By default, it captures the first catalog event on a page and includes that catalog’s details (like catalogObject and catalogEventId) in all time tracking events. You can configure which event types to capture using the eventTypes option.
Enable time tracking with default thresholds (30 seconds and 60 seconds) and a catalog context.
1SalesforceInteractions.init({
2 consents: [{
3 purpose: SalesforceInteractions.ConsentPurpose.Tracking,
4 provider: "OneTrust",
5 status: consentStatus
6 }],
7 dataCloud: {
8 timeTracking: {
9 enabled: true
10 }
11 }
12});Configure custom thresholds and event types.
1SalesforceInteractions.init({
2 consents: [{
3 purpose: SalesforceInteractions.ConsentPurpose.Tracking,
4 provider: "OneTrust",
5 status: consentStatus
6 }],
7 dataCloud: {
8 timeTracking: {
9 enabled: true,
10 thresholds: [
11 { label: 'ENGAGED', threshold: 15000 },
12 { label: 'HIGH_ENGAGEMENT', threshold: 60000 }
13 ],
14 eventTypes: ['catalog', 'blogPost']
15 }
16 }
17});Time tracking generates events with the Engagement category and automatically includes fields from captured context events.
| Field Name | Field Type | Description |
|---|---|---|
eventType | string | Dynamically set to {contextType}Time (for example, catalogTime). Events are only sent after a context event has been captured. |
interactionName | string | Either timeOnPage or pageExit. |
category | string | Always Engagement. |
threshold | string | The threshold label that was crossed (for example, LOW_INTEREST) or pageExit. |
totalActiveTime | number | Total milliseconds of active time for this context/session. |
pageStartTime | string | ISO 8601 timestamp when tracking started for this context. |
lastActivityTime | string | ISO 8601 timestamp of the most recent user activity. |
pageViewId | string | UUID v4 generated per page view to correlate events. |
pingSequence | number | Incrementing counter for events in this page view. |
When a context event (for example, a catalog event) is captured, its fields are automatically copied to time tracking events. For catalog contexts, this includes catalogObject and catalogEventId.
You can programmatically stop the time tracking service:
1SalesforceInteractions.DataCloud.stopTimeTracking()This is useful for:
Note: Once stopped, the service cannot be restarted without reinitializing the SDK.
maxEventsPerSession is at least thresholds.length + 1 to allow all thresholds plus pageExiteventTypes: ['catalog']eventTypes: ['catalog', 'custom']sendPageExitWithoutThreshold: false) filters out bounce visitstimeTracking.enabled: true is setmaxEventsPerSession hasn’t been exceeded