Radar’s tracking script is designed to capture key user interactions automatically while giving you the tools to let your customers track what’s unique to their sites.

Automatic Event Capture

Once installed on your customer’s site, Radar automatically captures $pageview and $pageleave events. You can enable more advanced automatic event tracking by setting the appropriate feature flags in your configuration.

Page Tracking (Enabled by Default)

  • $pageview: Fired every time a page is loaded or the URL hash changes. Includes details like the page URL, title, and referrer.
  • $pageleave: Fired when a user navigates away from a page. This event is used to calculate time-on-page metrics in session-based delivery.

Form Tracking (features.formTracking)

When you enable formTracking, Radar will automatically capture the following events on your customers’ websites:
  • form_submit: Fired when a user successfully submits a form. The event includes the form’s name, ID, and all non-sensitive field values.
  • form_abandon: Fired when a user interacts with a form’s fields but navigates away from the page without submitting.
Radar automatically redacts data from fields that appear to be sensitive (e.g., fields with names like password, credit_card, ssn).

Click & Download Tracking (features.clickTracking, features.downloadTracking)

  • Click Tracking: When you enable clickTracking, Radar automatically captures clicks on <a> and <button> elements, as well as any element with a data-track-event attribute on your customer’s site.
  • Download Tracking: When you enable downloadTracking, Radar will fire a download event when a user clicks a link that points to a common file type (e.g., .pdf, .docx, .zip).

Tracking Custom Events

For actions specific to your customers’ applications, you can provide documentation and examples showing them how to send custom events using the track method, which is exposed by the namespace you defined in the loader script.
// Your customer would implement this on their site
// to track a specific action.
YourAppName.track("CTA Clicked");
Advise your customers to use a consistent [Object] [Verb] naming convention to keep their events organized and readable. For example: File Downloaded, User Upgraded, or Video Played.

Adding Event Properties

You should instruct your customers on how they can enrich custom events with metadata by passing a second argument containing a JSON object. This is essential for capturing the full context of an action.
// Example for your customer's documentation
YourAppName.track("CTA Clicked", {
  cta_text: "Try for free",
  cta_position: "navbar-right",
});
These properties will be included in the event_properties object of the webhook payload you receive. See an example in Receiving Events.