WysLeap
WysLeap Docs

Installation

Get WysLeap tracking running on your site in under 2 minutes with a simple script tag. No build process required.

Step 1: Add the Tracking Script

Add this code to your site's <head> section. Replace your-site-id and your-api-key with the values from your WysLeap dashboard.

<script src="https://wysleap.com/telemetry.js"></script>
<script>
  WysLeap.init({
    siteId: 'your-site-id',
    options: {
      _apiKey: 'your-api-key',
      trackClicks: true,      // Automatically track click events
      trackScroll: true,      // Track scroll depth (enabled by default)
      trackWebVitals: true,   // Core Web Vitals from real visitors (enabled by default)
      privacy: true,          // Enable privacy mode (anonymize IP)
      disableBeacon: false,   // Use sendBeacon for better reliability
      sessionReplay: {
        enabled: true,        // Off by default; true turns replay on
        maskSensitive: true,  // Auto-mask passwords, emails, credit cards
        sampleRate: 0.5       // Record 50% of sessions (default: 1.0, all)
      }
    }
  });
</script>

Configuration Options

Basic Options

OptionWhat it doesDefault
trackClicksAutomatically track click eventstrue
trackScrollTrack scroll depthtrue
trackWebVitalsMeasure Core Web Vitals (LCP, INP, CLS, FCP, TTFB) in visitors' browsers, sent once per page viewtrue
privacyEnable privacy mode to anonymize IP addressesfalse
disableBeaconDisable the sendBeacon APIfalse

Session Replay

Session replay is off by default. Set sessionReplay.enabled: true to turn it on. It records user sessions for pixel-perfect replay (DOM snapshots, clicks, scrolls, form inputs).

  • sampleRate: share of sessions to record: 1.0 = all (default), 0.5 = 50%, 0.1 = 10%
  • All input fields are masked automatically (maskSensitive, on by default)
  • Event-based recording (not video) for a smaller data footprint
  • Per-event-type controls: recordMousemove, recordClick, recordScroll, recordInput, recordMedia
  • recordElement: record only specific page sections by CSS selector

See Session Replay for the full set of options.

SDK Methods

Once initialized, you can use these methods to track custom events and page views.

WysLeap.trackPageView()

Manually track a page view, for content that changes without a URL change. Route changes are tracked automatically.

WysLeap.trackPageView();

WysLeap.trackEvent(name, data)

Track a custom event with optional metadata.

WysLeap.trackEvent('button_click', {
  buttonId: 'signup',
  location: 'header'
});

WysLeap.visitorId

The current visitor's anonymous ID (read-only, available after init). It is null after WysLeap.setConsent(false).

console.log('Visitor ID:', WysLeap.visitorId);

WysLeap.setConsent(granted)

Record the visitor's choice. Visitors in the EU/EEA, UK and Switzerland are tracked only after true. false opts them out fully: tracking stops and their stored ID is removed.

WysLeap.setConsent(false); // opt out
WysLeap.setConsent(true);  // opt back in

Verify Installation

How to confirm it's working

  1. Open your browser's Developer Console (F12)
  2. Look for the WysLeap initialized message
  3. Visit your Analytics Dashboard
  4. Check for real-time visitor data (may take 10-30 seconds to appear)

Next Steps

Your site is now tracking pageviews and user behavior. Next, learn how to track custom events.