Hooks/callbacks
What are UXWizz callbacks?
The UXWizz callbacks or hooks are a way to tap into the client-side UXWizz tracking functionality and listen to specific events. This is useful, for example, if you want to read or forward some UXWizz tracking data to another service.
Available callbacks
UST.onLoaded()
Called as soon as the ust.min.js finishes loading.
UST.onTrackingStarted() : false | undefined
Called when all tracking checks passed, meaning that a new session will be created.
This is called before the session was created.
If you want to stop creating this session, return
false
from this function.
UST.onSessionCreated(clientID: number)
Called when the UXWizz server create a new session for this client
clientID: The integer number ID of the session.
This is called only once per visit for each visitor.
UST.onPageViewCreated(clientID: number, clientPageID: number)
Called when a new page has loaded and the server responded with the pageview ID.
clientID: The integer ID of the session.
clientPageID: The integer ID of the pageview.
This callback is also called once immediately after onSessionCreated (first pageview).
UST.onDataSent(data: string[])
Called whenever tracking data (session recording/heatmap data) is sent to the server.
data: An array of data strings sent to the server. Each data string is in the format
c=XXX
wherec
is the data type andXXX
is the data value. The data type can be:m - Heatmap movements
Data value is a Positions string
c - Heatmap clicks
Data value is a Positions string
p - Partial recording data
Data value is a Recording string
r - Full recording data (sent when pageview has finished)
Data value is a Recording string
x - Recording type
Data is an integer
w - We have a complete recording
Data is 1 (or not set)
s - Skip updating lastActivity
Useful for when we want to update data for a user, without automatically refreshing/increasing the user's session duration.
Data is 1 (or not set)
i - clientPageID
Data value is a number
UST.onTagAdded(tag: string)
Called when UST.addTag() was called and the server responded.
tag: The string that has just been added as a tag to the current user.
UST.onEventAdded(eventData: Event)
Added in version 3.5.0
Called when UST.addEvent() was called and the server responded.
eventData: The original eventData passed, also containing clientID and clientPageID
UST.onGDPRAccepted()
Called when the user accepted the UXWizz tracking consent pop-up.
UST.onGDPRDeclined()
Called when the user declined the UXWizz tracking consent pop-up.
Usage example
Make sure write the callbacks declarations after the tracking file is included.
Example: Multiple UXWizz callbacks
Example: Dynamically disable tracking the current visitor
Example: Track the current user but disable session recording
After the session has been created (onSessionCreated), you can always read the current userTrack clientID and clientPageID from sessionStorage:
sessionStorage.getItem('clientPageID')
sessionStorage.getItem('clientID')
sessionStorage.getItem('token') token - Another unique identifier per session (similar to clientID). This is useful as it's not incremental.
Notes
Positions string (compressed format):
Recording string (compressed format)
Last updated