Proxy The Snippet Through Your Own Subdomain

Serve the tracking snippet from a subdomain of your own site, such as a.example.com, so visitors with an ad blocker are counted too.

Updated

Ad blockers keep lists of analytics addresses and stop the browser from loading anything from them. behavly.io is on some of those lists, so a visitor with an ad blocker never loads the snippet and never appears in Behavly: no page views, no clicks, no heatmap, no identity.

The answer is to serve the snippet from a subdomain of your own site, such as a.example.com. To the browser it is part of your site, so the lists that name behavly.io do not match it. Behavly runs the subdomain for you: you add a DNS record, and Behavly takes care of the server and the SSL certificate.

Set It Up

  1. 1Go to Tracking → Setup and press the code icon next to the site.
  2. 2Open Proxy through your own subdomain at the bottom of the dialog, enter a new subdomain of that site, such as a.example.com, and press Add subdomain.
  3. 3Add the records Behavly shows at your DNS provider: a CNAME record for the subdomain and, when Behavly asks for one, a TXT record that proves the domain is yours. Each value has a copy button.
  4. 4Press Check status. It says Pending until the records are live and the certificate is issued, then Active. That usually takes a few minutes and can take up to 48 hours.
  5. 5Once it says Active, change the src of your script tag to the subdomain and deploy your site. The rest of the tag stays as it is.
<script async src="https://a.example.com/t.js" data-pid="YOUR_WRITE_KEY"></script>

From then on the snippet sends everything to the subdomain: page views, clicks, identity and the heatmap overlay. Your data, write key and settings stay as they were, and visitors' countries and cities are still recorded correctly.

StatusWhat it means
Pending
Behavly has added the subdomain and is waiting for your DNS records. The dialog lists the records to add.
Active
The records are live and the certificate is issued. Switch the tag's src to the subdomain.
Error
The subdomain is no longer connected to Behavly. Remove it and add it again.

The subdomain serves the snippet and nothing else. Any other address on it, including its home page, answers 404 Not found.

Pick A Neutral Name

Ad blockers also block by name. A subdomain with analytics, tracking, stats or behavly in it is the kind of name the lists pick up, so Behavly does not accept one. Choose something short that says nothing, such as a, x or go.

  • It must be a new subdomain that nothing else uses. Your site's own address, such as example.com or www.example.com, cannot be the proxy.
  • It must be under the same domain as the site. A site on shop.example.com can use a.example.com.
  • One subdomain per site. To change it, remove the first one and add the new one.

Content Security Policy

If your site sends a Content-Security-Policy header, add the subdomain to script-src, so the browser loads the snippet, and to connect-src, so the snippet can send what it records. Add it to the sources you already list rather than replacing them:

Content-Security-Policy: script-src 'self' https://a.example.com; connect-src 'self' https://a.example.com

Without it the browser blocks the snippet just as an ad blocker would, and says so in the console.

Remove It

  1. 1Change the tag's src back to https://behavly.io/t.js and deploy your site.
  2. 2In the same dialog, press Remove and confirm.
  3. 3Delete the DNS records at your DNS provider.

Remove the subdomain only once your tag no longer loads from it. From the moment you press Remove the subdomain serves nothing, and a tag that still points at it records nothing until you change it.

Deleting the site from Behavly removes its subdomain too. View-only members can see the subdomain and its status, but cannot add, check or remove it.

Prefer Your Own Server?

If you would rather send the snippet through a server or edge you already run, Proxy The Snippet Through Your Own Server has setups for Next.js, Express, PHP, Nginx, Caddy, Laravel, Flask, FastAPI, Cloudflare Workers and Netlify. Each one passes on the visitor's address, so countries are still right.

Still stuck? Ask Behavly Agent from inside the app — it can explain any part of Behavly, though it cannot see your data. Or email hello@behavly.io.