WysLeap

Documentation

Onboarding guide

Get from zero to live analytics in minutes: installation, custom events, SaaS metrics, AI observability, and session replay.

Step 02 of 9: Installation

Onboarding guide

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.

html
<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

  • trackClicks: Automatically track click events (default: true)
  • trackScroll: Track scroll depth (default: true)
  • trackWebVitals: Measure Core Web Vitals (LCP, INP, CLS, FCP, TTFB) in visitors' browsers, sent once per page view (default: true)
  • privacy: Enable privacy mode to anonymize IP addresses (default: false)
  • disableBeacon: Disable sendBeacon API (default: false)

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

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.

javascript
WysLeap.trackPageView();

WysLeap.trackEvent(name, data)

Track a custom event with optional metadata.

javascript
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).

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

WysLeap.setConsent(granted)

Record the visitor's choice. false opts them out fully: tracking stops and their stored ID is removed.

javascript
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 WysLeap initialized message
  3. Visit your Analytics Dashboard
  4. Check for real-time visitor data (may take 10-30 seconds to appear)

Installation Complete!

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

Next: Custom Events →