Docs/Tracking Script

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.

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.

index.html
html
<!-- 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

Your site key is available in the ClearView dashboard under Settings → Sites. Click on the site name to copy the key to your clipboard.

For Next.js applications, use the built-in Script component:

app/layout.tsx
tsx
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:

Google Tag Manager - Custom HTML
html
<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:

1

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.

2

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.

3

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.

It can take up to 60 seconds for the first event to appear in your dashboard after installation. If you do not see data after 2 minutes, check the Troubleshooting section below.

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:

manual-pageview.js
javascript
// Manually trigger a page view
if (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 URL

The full URL of the page being viewed, including path and query parameters.

Referrer

The referring URL that led the visitor to the current page.

Timestamp

The exact date and time of the page view event.

Session ID

A first-party cookie used to group page views into sessions. Expires after 30 minutes of inactivity.

Visitor ID

A first-party cookie used to recognize returning visitors. Expires after 1 year.

User Agent

The browser's user agent string, used to determine device type and browser.

Screen Size

The visitor's screen resolution for device categorization (desktop, tablet, mobile).

Language

The browser's language setting.

UTM Params

Campaign tracking parameters (utm_source, utm_medium, utm_campaign, etc.) if present in the URL.

What is NOT collected

ClearView does not collect keystrokes, form inputs, mouse movements, scroll depth, personal information, or any data from third-party cookies. The script does not inject any visible elements into your page.

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-out.js
javascript
// Opt a visitor out of tracking
if (window.clearview) {
window.clearview("optout");
}
// Check if a visitor has opted out
if (window.clearview) {
const isOptedOut = window.clearview("isOptedOut");
console.log("Opted out:", isOptedOut);
}
// Conditionally load the script based on consent
if (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:

AttributeDefaultDescription
data-siteRequiredYour unique site key
data-autotrueAutomatically track page views. Set to false for manual tracking only.
data-spatrueEnable SPA route change detection. Set to false if you only want to track initial page loads.
data-track-querytrueInclude query parameters in tracked URLs. Set to false to strip query strings.
data-excludeNoneComma-separated list of URL patterns to exclude from tracking (e.g., /admin/*,/internal/*).
data-respect-dntfalseWhen set to true, the script will not track visitors whose browser has Do Not Track enabled.
index.html
html
<!-- 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-site attribute 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-spa is not set to false.
  • If your framework uses hash-based routing, ClearView detects hashchange events 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 async attribute 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?

If you've tried the steps above and the script still isn't working, visit the full Troubleshooting & FAQ page or contact our support team at support@democlearview.com.