Self-hosting

Ad blockers and analytics: using a first-party proxy

Ownlytics team · · 6 min read

Ad blockers can stop an analytics script from loading, so some of your visitors never appear in your reports. Serving the script and its events through your own domain, a first-party proxy, makes your tracker look like part of your site and can recover a share of that traffic.

Ad blocker on

Third-party scriptoften blocked
Visits recordedundercounted

First-party proxy

Script served fromyour own domain
Visits recordedfar fewer blocked

Fig.Why serving the script from your own domain changes what you can count. Sample data, not a real site.

Why do ad blockers hide visitors from analytics?

Most blockers work from lists of known tracker domains and URL patterns. When your page asks for a script from a well-known third-party analytics domain, the blocker can refuse the request, so the script never runs and the visit is never counted.

The visitor still browses your site, and if they buy, your payment provider still records the sale. The result is a gap you may notice: sales that cannot be tied to a visit, or revenue from a source your traffic charts barely show.

The size of the gap depends on your audience and we cannot give you a figure for your site, so measure it (see below). Technical audiences may well use blockers more, but check that against your own data rather than assuming it.

What is a first-party proxy?

Blocklists target third-party analytics domains. If the script and the events go through your own domain, they look like the rest of your site.

So instead of the browser calling the analytics provider directly, it calls a path on your domain, such as /js/script.js for the script and /api/events for events. A small piece of code on your domain forwards those requests to your analytics install and returns the answer.

For Ownlytics on Cloudflare, you add a short function to your site's Worker. It does these things, per the proxy docs:

Then you load the script from /js/script.js on your domain. The setup page fills in your URL and token. The token works only for that one website.

Who can use it?

The documented setup is for sites that run on Cloudflare Workers. If your site runs elsewhere, the same idea (forward a path on your domain to your analytics) can be built with your own server or host's rewrite rules, but we do not have a ready-made recipe for every platform, so check your host's documentation. The tracking script guide lists where to paste the tag for common platforms, and mentions the proxy for Cloudflare sites.

Example (made-up numbers for illustration)

Suppose a developer tools site has 10,000 real visits a month, and 18% of visitors use a blocker.

SetupVisits recordedMissing
Third-party script, blocker users hiddenabout 8,200about 1,800
First-party proxy, blockers no longer matchcloser to 10,000fewer, but not zero

The numbers are invented. What matters is the direction: you would see more visits and, more usefully, fewer sales that arrive without a visit. If your proxy recovers only half the hidden visitors, that is still a better picture of where buyers came from.

How can you check how much you are missing?

Do not guess. Run this checklist:

  1. Compare sales to visits. Count sales over the last 30 days. Count how many your attribution could link to a visit, see sources and attribution. A large unlinked share is a hint of blocked scripts, though other causes exist.
  2. Test with a blocker. Open your site in a browser with a common blocker on, and watch your realtime view. If your visit does not show, the script is being blocked.
  3. Set up the proxy. Load the script from your own domain.
  4. Test again. Repeat step 2 and check that the visit now appears.
  5. Wait two weeks. Compare the sales-linked share to before.
yourapp.comToday7d30d9 online
SourceVisitorsSalesRevenue
Xx.com6,2479$441
Ggoogle.com4,43314$686
@newsletter1,1307$343
Ynews.ycombinator.com2,0153$147
Cchatgpt.com1,4114$196
↗Direct · typed or bookmark1,2092$98

Fig.Sources counted after the first-party proxy. Sample data, not a real site.

What are the limits?

A proxy is not a cure.

When this doesn't apply

If your audience rarely uses blockers, or you have only a few visits a day, the gain will be small and not worth a deploy. If your goal is revenue, remember that sales also reach Ownlytics from your payment provider, so revenue totals do not depend on the script. What the proxy protects is the link from sale to source.

Also remember that fake visits are the opposite problem. Our post on bot and referrer spam covers filtering them.

At a glance

QuestionAnswer
What does the proxy change?Script and events load from your domain
What does it need?A Cloudflare Worker (documented setup)
Does it fix every blocker?No
Does it change revenue totals?No, only visit coverage and linking
Do your cookies leave your domain?No, the proxy removes them from forwarded requests

Try it

The proxy setup is covered in the docs, and plans for self-hosted and hosted are on the pricing page.

FAQ

Will a proxy get all my blocked traffic back?

No. It helps against domain-based blocking but not against every pattern or against visitors with JavaScript off. Treat it as recovering a share, and measure the change.

Does the proxy hide data from my visitors or from me?

Neither. It only changes the path the requests take. Your analytics receives the same events, with accurate location and IP passed through your token.

Do I need a proxy if I only care about revenue?

Not for revenue totals, which come from your payment provider. The proxy helps most with linking sales to the visits and sources that produced them.

Is using a proxy allowed under privacy law?

Rules depend on what you collect and where you operate. This is general information, not legal advice, so ask your own counsel or regulator.

See the live demo · View pricing

Keep reading