Tracking Script
The ClearView tracking script is a lightweight JavaScript snippet that identifies companies visiting your website. Learn how to install, configure, and verify it.
On this page
Installation
Add the ClearView tracking script to your website by placing the following snippet in the <head> section of your HTML. Replace your-site-key with the site key from your ClearView dashboard.
<!-- ClearView Tracking Script --><script async src="https://democlearview.com/api/track/t.js" data-site="your-site-key"></script>Where to find your site key
For Next.js applications, use the built-in Script component:
import Script from "next/script";export default function RootLayout({ children,}: { children: React.ReactNode;}) { return ( <html lang="en"> <body> {children} <Script src="https://democlearview.com/api/track/t.js" data-site="your-site-key" strategy="afterInteractive" /> </body> </html> );}For Google Tag Manager, add a Custom HTML tag:
<script async src="https://democlearview.com/api/track/t.js" data-site="your-site-key"></script>How It Works
The ClearView tracking script works in three stages to identify the companies visiting your website:
Page View Capture
When a visitor loads a page, the script fires an asynchronous request to the ClearView API with the page URL, referrer, and a first-party session cookie. The script is under 4KB gzipped and loads asynchronously, so it has zero impact on your page performance.
IP Resolution
ClearView resolves the visitor's IP address against a proprietary database of company IP ranges, ISP mappings, and corporate network signatures. This process identifies the company behind the visit without requiring any personal data.
Data Enrichment
Once a company is identified, ClearView enriches the record with firmographic data including company name, industry, employee count, revenue range, location, website, and social profiles. This data appears in your dashboard within seconds.
Verification
After installing the script, verify it is working correctly:
Dashboard verification
Navigate to Settings → Sites in your dashboard. A green checkmark next to your site name confirms that ClearView is receiving tracking events.
Browser DevTools check
Open your browser's Developer Tools (F12), go to the Network tab, and reload your page. Look for a request to t.js followed by a POST request to the ClearView API. A 200 status code means the script is working.
Dashboard confirmation
Visit your website, then check the Visitors page in your dashboard. Your visit should appear shortly, confirming end-to-end data flow.
SPA Support
The ClearView tracking script automatically supports Single Page Applications (SPAs) built with React, Vue, Angular, Next.js, Nuxt, and other modern frameworks. No additional configuration is needed.
How SPA tracking works
The script listens for changes to the browser's History API (pushState and replaceState) as well as popstate events. When a route change is detected, a new page view event is automatically sent to ClearView.
This means every client-side navigation is tracked, giving you the full picture of how visitors browse your site, not just the initial page load.
If you need to manually trigger a page view (for example, in a modal or virtual page), you can call the global tracking function:
// Manually trigger a page viewif (window.clearview) { window.clearview("pageview", { url: "/custom/virtual-page", title: "Custom Page Title", });}Data Collected
ClearView collects the minimum data needed to identify companies and track page views. Here is a complete list of data points captured by the tracking script:
Page URLThe full URL of the page being viewed, including path and query parameters.
ReferrerThe referring URL that led the visitor to the current page.
TimestampThe exact date and time of the page view event.
Session IDA first-party cookie used to group page views into sessions. Expires after 30 minutes of inactivity.
Visitor IDA first-party cookie used to recognize returning visitors. Expires after 1 year.
User AgentThe browser's user agent string, used to determine device type and browser.
Screen SizeThe visitor's screen resolution for device categorization (desktop, tablet, mobile).
LanguageThe browser's language setting.
UTM ParamsCampaign tracking parameters (utm_source, utm_medium, utm_campaign, etc.) if present in the URL.
What is NOT collected
Privacy
ClearView uses only first-party cookies set on your domain. No third-party cookies, no cross-site tracking, and no fingerprinting.
Opt-out support
If you need to offer visitors an opt-out mechanism, you can conditionally load the script or use the built-in opt-out function:
// Opt a visitor out of trackingif (window.clearview) { window.clearview("optout");}// Check if a visitor has opted outif (window.clearview) { const isOptedOut = window.clearview("isOptedOut"); console.log("Opted out:", isOptedOut);}// Conditionally load the script based on consentif (userHasConsented) { const script = document.createElement("script"); script.src = "https://democlearview.com/api/track/t.js"; script.dataset.site = "your-site-key"; script.async = true; document.head.appendChild(script);}Advanced Configuration
The tracking script supports several data attributes for advanced configuration:
| Attribute | Default | Description |
|---|---|---|
data-site | Required | Your unique site key |
data-auto | true | Automatically track page views. Set to false for manual tracking only. |
data-spa | true | Enable SPA route change detection. Set to false if you only want to track initial page loads. |
data-track-query | true | Include query parameters in tracked URLs. Set to false to strip query strings. |
data-exclude | None | Comma-separated list of URL patterns to exclude from tracking (e.g., /admin/*,/internal/*). |
data-respect-dnt | false | When set to true, the script will not track visitors whose browser has Do Not Track enabled. |
<!-- Example with advanced configuration --><script async src="https://democlearview.com/api/track/t.js" data-site="your-site-key" data-spa="true" data-track-query="false" data-exclude="/admin/*,/internal/*"></script>Troubleshooting
Common issues and how to resolve them:
Script not loading
- •Verify the script tag is placed inside the
<head>or before the closing</body>tag. - •Check for ad blockers or browser extensions that might be blocking the script.
- •Ensure your Content Security Policy (CSP) allows loading scripts from
democlearview.com.
No data in dashboard
- •Confirm the
data-siteattribute matches your site key exactly (case-sensitive). - •Open DevTools and check the Console for any ClearView-related error messages.
- •Check the Network tab for failed requests to the ClearView API.
- •Ensure your domain matches the one configured in your site settings.
SPA route changes not tracked
- •Ensure
data-spais not set tofalse. - •If your framework uses hash-based routing, ClearView detects
hashchangeevents automatically. - •For custom routing solutions, use the manual page view API described in the SPA Support section above.
Script affecting page performance
- •The script loads asynchronously and should not block rendering. Confirm the
asyncattribute is present on the script tag. - •The gzipped script size is under 4KB. If you observe significant performance impact, another resource on your page is likely the cause.
Still having issues?