Documentation
Add PerchLens to your website in under 30 seconds. One script tag, no build tools, no configuration.
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.
<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.
Track custom events like button clicks, form submissions, or video plays using the window.cv() function.
// 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.
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.
<!-- 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>The script supports these optional attributes:
| Attribute | Description | Default |
|---|---|---|
| data-site | Your unique tracking ID (required) | - |
| data-api | Custom API endpoint for event collection | /api/collect |
<!-- Custom API endpoint -->
<script defer
src="https://perchlens.com/cv.js"
data-site="cv_8f3k2j5m9x"
data-api="https://your-api.com/api/collect"
></script>PerchLens is privacy-friendly by design. Here's what we do and don't collect:
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.
If you're not seeing data in your dashboard, try these steps:
Open your browser DevTools (F12) → Network tab → filter by "cv.js". You should see a 200 response for the script file.
In the Network tab, filter by "collect". You should see POST requests to /api/collect returning 202 status.
Make sure the data-site attribute matches the tracking ID shown in your site Settings page.
After your first pageview, it can take up to 30 seconds for data to appear in the dashboard. The Realtime view updates fastest.