Add the Tracking Script
How to install the PixelsCleared tracking script on your website.
Copy the Script Tag
- Sign in to the PixelsCleared dashboard.
- Go to Gateway in the sidebar and open your tenant.
- Scroll to the Tenant Setup section.
- Copy the script tag shown. It will look like this:
<script src="https://track.yourdomain.com/pixelscleared.js"></script>
Replace track.yourdomain.com with the CNAME subdomain you configured for this tenant. The script URL always follows the pattern:
https://your-cname/pixelscleared.js
The script loads from your own first-party domain, not from PixelsCleared directly. This means ad blockers and browser privacy extensions will not block it.
Where to Place the Script
Add the script tag to every page on your website. There are two common placements:
Before closing </body> (recommended):
<!-- your page content -->
<script src="https://track.yourdomain.com/pixelscleared.js"></script>
</body>
</html>
In the <head> section:
<head>
<!-- other head content -->
<script src="https://track.yourdomain.com/pixelscleared.js"></script>
</head>
Placing the script in the <head> ensures it loads earlier, which is useful if you want to capture events on initial page load. Placing it before </body> avoids blocking other page resources.
If your site uses a shared template or layout file, add the script tag there once rather than on every individual page.
Verify the Script Is Working
After adding the script, confirm it is loading correctly:
- Open your website in a browser.
- Open the browser developer tools (press F12 or Ctrl+Shift+I on Windows, Cmd+Option+I on Mac).
- Switch to the Network tab.
- Reload the page.
- Look for a request to
pixelscleared.json your CNAME domain (for example,track.yourdomain.com/pixelscleared.js). - The request should return a 200 status code.
If the request shows a 404 or fails to appear, check that your CNAME DNS record is correctly configured and has propagated. See the DNS CNAME Setup guide for details.
Once the script loads and a visitor grants consent, events will start appearing in the Gateway > Events section of your dashboard within seconds.
Manual Consent API
By default, the script detects consent from popular consent management platforms (Cookiebot, OneTrust, CookieYes, Complianz) and IAB TCF v2. If you use a custom consent mechanism or want to control consent programmatically, call:
window.PixelsCleared('consent', true);
To revoke consent:
window.PixelsCleared('consent', false);
The script will not send any events until consent is granted. If consent is revoked, the script stops sending immediately and clears its local state.