namespace
you defined. This JavaScript SDK provides a set of methods that your customers can use to send custom data, manage their users’ identity, and control the tracker’s behavior.
Throughout this guide, we’ll use YourAppName
as the example namespace that you would provide to your customers.
Core Methods
track
Thetrack
method is the primary way for your customers to send custom event data to Radar.
The name of the event to track. You should advise your customers to use a consistent
[Object] [Verb]
naming convention, such as Document Signed
or Video Played
.A JSON object of key-value pairs to send as metadata with the event.
identify
Theidentify
method allows your customers to associate traits with a user on their website. These traits are stored by Radar and attached to all future events from that user.
A JSON object of key-value pairs representing the user’s traits. If an
email
property is included, Radar will use it for enrichment.page
While Radar tracks pageviews automatically in most cases, thepage
method can be used to manually trigger a pageview event. This is useful in Single-Page Applications (SPAs) where routing changes don’t always trigger a full page load.
Session Management
getSession
Returns the current session object for the end user.resetSession
Ends the current user’s session and immediately starts a new one.Consent Management
giveCookieConsent
This method signals to Radar that an end user has provided consent to use persistent storage (cookies andlocalStorage
). See the Consent Management guide for a full walkthrough.
Advanced Methods
flush
Forces the tracker to immediately send any queued events to the Radar API. This can be useful for your customers in specific situations where they need to ensure data is sent before a certain action.on
Allows you to build functionality that listens for events emitted by the tracker on your customer’s site. Your customers can use this to integrate the tracker’s lifecycle with their own application code.The name of the internal tracker event to listen for. Common events include:
initialized
, session_start
, identify
, page_view
.A function to execute when the event occurs. The callback will receive the event payload as an argument.