Documentation

Getting Started

Add PerchLens to your website in under 30 seconds. One script tag, no build tools, no configuration.

1. Quick Start

Add the PerchLens tracking script to your website by pasting this snippet just before the closing </head> tag on every page you want to track.

html
<script defer src="https://perchlens.com/cv.js" data-site="YOUR_TRACKING_ID"></script>

Replace YOUR_TRACKING_ID with the tracking ID from your site settings. You can find this on the Settings page after adding your site.

That's it. Pageviews are tracked automatically. No npm install, no build step, no config files.

2. Custom Events

Track custom events like button clicks, form submissions, or video plays using the window.cv() function.

javascript
// Track a simple event
window.cv('signup');

// Track an event with properties
window.cv('purchase', {
  plan: 'pro',
  value: '9'
});

// Track a button click
document.querySelector('#cta-button').addEventListener('click', () => {
  window.cv('cta_click', { location: 'hero' });
});

Events appear in your Conversions dashboard. You can set up conversion goals to track specific events and measure their performance over time.

3. Single-Page Apps (SPA)

PerchLens automatically tracks page navigations in single-page applications. It hooks into history.pushState and the popstate event, so frameworks like Next.js, React Router, Vue Router, and SvelteKit work out of the box.

No additional configuration is needed. Just add the script tag and it handles the rest.

html
<!-- Works automatically with: -->
<!-- Next.js, Remix, Astro, Nuxt, SvelteKit, -->
<!-- React Router, Vue Router, Angular Router -->

<!-- Just add the script tag to your root layout -->
<script defer src="https://perchlens.com/cv.js" data-site="YOUR_TRACKING_ID"></script>

4. Configuration

The script supports these optional attributes:

AttributeDescriptionDefault
data-siteYour unique tracking ID (required)-
data-apiCustom API endpoint for event collection/api/collect
html
<!-- Custom API endpoint -->
<script defer
  src="https://perchlens.com/cv.js"
  data-site="cv_8f3k2j5m9x"
  data-api="https://your-api.com/api/collect"
></script>

5. Privacy

PerchLens is privacy-friendly by design. Here's what we do and don't collect:

What we collect

  • Page URL and path
  • Referrer URL
  • Country (from IP, not stored)
  • Device type and browser
  • Screen width
  • UTM parameters

What we never collect

  • IP addresses (not stored)
  • Cookies
  • Personal information
  • Fingerprints
  • Cross-site tracking
  • User profiles

Because we don't use cookies or collect personal data, you don't need to show cookie consent banners. PerchLens is compliant with GDPR, CCPA, and PECR out of the box.

6. Troubleshooting

If you're not seeing data in your dashboard, try these steps:

Check the script is loaded

Open your browser DevTools (F12) → Network tab → filter by "cv.js". You should see a 200 response for the script file.

Check events are being sent

In the Network tab, filter by "collect". You should see POST requests to /api/collect returning 202 status.

Verify your tracking ID

Make sure the data-site attribute matches the tracking ID shown in your site Settings page.

Data takes a moment

After your first pageview, it can take up to 30 seconds for data to appear in the dashboard. The Realtime view updates fastest.