Bypass ad blockers
Even though Umami is a privacy-focused product, it may still get blocked by
certain ad blockers. Ad blockers use blocklists maintained by many different people.
Some lists can be overly agressive, for example blocking anything with even
the word analytics
in it or simply blocking all tracking products regardless
of how they operate.
Here are few methods you can use to avoid ad blockers.
Proxying
Proxying is done at the server level so you will need access to your web server to make changes. With this method, you can proxy the tracking script itself to hide the actual name and location of the original script.
For example, you can have a script on your website that is:
https://your-website.com/script.js
That is proxying the file at:
https://cloud.umami.is/script.js
So even if the ad blocker blocks the cloud.umami.is
domain, your own domain would be safe.
Here are some tutorials you can use:
If you are using a framework like Next.js, you can use their rewrites feature.
Hosting the tracker script
If you don't have access to the web server and are unable to proxy the script, you can simply host the entire tracker script on your own domain.
- Open the the script URL in your browser,
https://cloud.umami.is/script.js
. - Save the file.
- Upload the file to your domain.
- Set the
data-host-url
attribute to send data to the correct location. See tracker configuration.
Note that this method is not as reliable as proxying and if the tracker script were to change, you would need to download and update the script again.
Using environment variables (self-hosting)
If you are self-hosting Umami, you can configure your instance using environment variables.
There are two sources that could potentially be blocked:
- The tracker script at
https://your-umami.com/script.js
- The stats collection endpoint at
https://your-umami.com/api/send
.
The TRACKER_SCRIPT_NAME
variable can be used to rename your tracker script to
something like /x.js
. You would then change your script source to https://your-umami.com/x.js
.
The COLLECT_API_ENDPOINT
variable can be used to rename your endpoint to something
like /api/x
. The tracker script will automatically make calls to your custom endpoint name
instead of /api/send
.