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.
Goals let you track page visit targets. Set a goal for any URL path and monitor progress on the Conversions page. Goals are available on the Pro plan (up to 20 per site).
To create a goal: go to Conversions → click "Create Conversion" → choose "Page Visit" → enter the path (e.g. /pricing) and a target count.
The goal progress bar shows how many visits the page has received relative to your target. You can also create goals programmatically via the API:
curl -X POST https://perchlens.com/api/goals \
-H "Content-Type: application/json" \
-d '{ "siteId": "your-site-id", "name": "Pricing visits", "path": "/pricing", "target": 100 }'PerchLens automatically tracks Core Web Vitals from real visitor browsers — no extra setup required. The tracking script measures LCP (Largest Contentful Paint), CLS (Cumulative Layout Shift), and FID (First Input Delay) and sends them when the visitor leaves the page.
Metrics are displayed on the Overview page with color-coded scores: green (Good), yellow (Needs Improvement), and red (Poor) based on Google's thresholds. Values shown are p75 (75th percentile) — the same metric Google uses for Core Web Vitals assessment.
Web Vitals data appears automatically once your site receives traffic with the latest tracking script (v1.4+). No configuration needed.
Invite up to 5 team members to view your analytics dashboard. Go to Settings → Team Members → click "Invite" and enter their email address.
Team members can be assigned one of two roles:
| Role | Permissions |
|---|---|
| viewer | View all analytics data (default) |
| editor | View data + manage goals and settings |
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.