Skip to content

Setup & Integration

Installation: Tracker Script & WordPress Plugin

Add the asynchronous SessionLens loader (t.js) and optional instant-visitor presence pixel (p.gif) to your website, configure the WordPress plugin, and exclude the tracker from caching delays.

1. Copy your Site Key and tracker snippet from Setup

In the SessionLens dashboard, select your site in the top-left switcher and click Configure → Setup (/app/sites/:siteId/settings). Under "1. Add the code to your site", click Copy to copy your site-specific <script> tag and paste it inside the <head> of every page.

<script async data-cfasync="false" nowprocket data-no-optimize="1" data-no-defer="1" src="https://app.otpshare.site/t.js" data-site="YOUR_SITE_KEY"></script>
  • WordPress (without plugin): Install "WPCode" or "Insert Headers and Footers" and paste the snippet into the Header section.
  • Shopify: Go to Online Store → Themes → Edit code → theme.liquid and paste the snippet right before </head>.
  • Google Tag Manager: Create a "Custom HTML" tag, paste the snippet, and set the trigger to All Pages.
  • React / Next.js: Add the script to index.html or load it in your root layout with next/script.

2. Add the 1-pixel instant-visitor image (recommended)

Speed optimization plugins often delay all JavaScript until the visitor clicks, scrolls, or taps. In Configure → Setup under "2. See every visitor from the first second", copy the 1-pixel <img> snippet and paste it immediately after the opening <body> tag (not inside <head>). Because browsers do not delay an eager 1×1 image, visitors appear in Live immediately and transition into the full session recording as soon as t.js starts.

<img src="https://app.otpshare.site/p.gif?k=YOUR_SITE_KEY" alt="" width="1" height="1" loading="eager" fetchpriority="high" data-no-lazy="1" data-skip-lazy="1" class="skip-lazy no-lazy" referrerpolicy="no-referrer-when-downgrade" style="position:absolute;width:1px;height:1px;opacity:0;pointer-events:none">
  • WordPress (WPCode / Insert Headers and Footers): Paste into the Body section (not Header).
  • Shopify: In theme.liquid, paste on the line immediately after <body ...>.
  • Elementor / theme builders: Use Custom Code with location set to "<body> – Start".
  • Do not place the <img> tag inside Google Tag Manager, because GTM itself is JavaScript and subject to script delay.

3. Install via the official WordPress plugin

If your store runs on WordPress or WooCommerce, you can use the dedicated SessionLens plugin located in wordpress-plugin/sessionlens instead of editing theme templates manually.

WP Admin → Settings → SessionLens
- Site Key: YOUR_SITE_KEY (letters, numbers, hyphens, underscores; up to 64 chars)
- Server Origin: https://app.otpshare.site
- Disable for Administrators: Checked by default (skips users with manage_options)
- Respect Do Not Track (DNT): Adds data-respect-dnt="true"
- Require Consent Before Recording: Adds data-require-consent="true"
- Enable Instant Presence Pixel: Outputs p.gif on wp_body_open
  • Upload the sessionlens plugin folder to /wp-content/plugins/sessionlens/ (or upload the ZIP in Plugins → Add New → Upload Plugin) and click Activate.
  • Open Settings → SessionLens in WP Admin and paste your Site Key from the dashboard Setup page.
  • The plugin automatically outputs the script in wp_footer with data-cfasync="false", nowprocket, data-no-optimize="1", and data-no-defer="1" attributes.
  • Keep "Disable for Administrators" enabled so store admins browsing the site are not recorded.

4. Configure cache & speed plugins and verify installation

After adding the snippet or enabling the WordPress plugin, check the installation status banner at the top of Configure → Setup. It polls every 10 seconds and reports when the last visitor was seen and whether script startup is delayed (> 2.5 seconds).

https://yourstore.com/?sl_debug=1
  • WP Rocket: Under File Optimization → Delay JavaScript execution → Excluded JavaScript Files, add app.otpshare.site (or your self-hosted domain). Also add it to Load JavaScript deferred and Combine JavaScript exclusions, then Clear cache.
  • LiteSpeed Cache: Under Page Optimization → JS Settings → JS Excludes and JS Deferred / Delayed Excludes, add app.otpshare.site, then run Toolbox → Purge All.
  • Cloudflare: Keep Rocket Loader off or rely on data-cfasync="false". If using a "Cache Everything" rule, bypass cache for /api/* and run Caching → Purge Everything.
  • Always load /t.js from the SessionLens server rather than copying the file to your own host so your site always receives the current loader.

Ready to configure your site?

Open Configure → Setup in your SessionLens dashboard to copy your site key, or start with the Free plan (1 website, 1,000 recorded sessions/month).