Acquisition
| Name | Visits | Share | Change |
|---|---|---|---|
| 2,331 | +12.4% | ||
| direct | 1,140 | +4.1% | |
| pinterest.com | 596 | +31.8% | |
| facebook.com | 371 | -6.2% | |
| bing.com | 169 | +2.9% | |
| duckduckgo.com | 84 | 0.0% |
Do you need web statistics for sites that are not editable? Your reverse proxy is the method for adding the code. It puts the StatJolt tracking code into every page on its way to the visitor. You don't touch the app at all.
Some apps have no method for adding a badge or tracking code. Bookorbit and Grimmory for hosting eBooks/audiobooks are good examples. If you use Caddy for reverse proxy, or Nginx, Apache or Traefik, this page gives you the config.
This code has no data-user number. Copy your code again from your StatJolt account.
Do you use Caddy for reverse proxy? Caddy needs the replace-response plugin. It changes the page before Caddy sends it out.
Build Caddy with the plugin:
xcaddy build --with github.com/caddyserver/replace-response
Do you run Caddy in Docker? Build your own image with this Dockerfile:
FROM caddy:2-builder AS builder
RUN xcaddy build --with github.com/caddyserver/replace-response
FROM caddy:2
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
Put this site block in your Caddyfile. Use your own port:
example.com {
replace {
match {
header Content-Type text/html*
}
</body> `<script async src="https://statjolt.com/measure/c.min.js" data-user="YOUR_ID"></script></body>`
}
reverse_proxy localhost:8080 {
header_up Accept-Encoding identity
}
}
Restart Caddy with the new build.
The plugin can't change a compressed page. The header_up line asks your app for an uncompressed page. The match block keeps the change on HTML pages only.
Nginx changes the page with the sub_filter directive. It needs the sub module. Check that your Nginx has it:
nginx -V 2>&1 | grep -o with-http_sub_module
If you see with-http_sub_module, you're ready.
Add these lines to the server block of your app. Use your own port:
server {
server_name example.com;
# keep your listen and ssl lines here
location / {
proxy_pass http://localhost:8080;
proxy_set_header Accept-Encoding "";
sub_filter '</body>' '<script async src="https://statjolt.com/measure/c.min.js" data-user="YOUR_ID"></script></body>';
}
}
Test the config and reload Nginx:
sudo nginx -t && sudo nginx -s reload
sub_filter can't change a compressed page. The proxy_set_header line asks your app for an uncompressed page. By default Nginx only changes HTML pages, so your other files stay as they are.
Apache changes the page with the mod_substitute module.
Turn on the modules. On Debian and Ubuntu:
sudo a2enmod substitute headers proxy proxy_http
Add these lines to the <VirtualHost> block of your app. Use your own port:
<VirtualHost *:443>
ServerName example.com
# keep your SSL lines here
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
RequestHeader unset Accept-Encoding
<Location "/">
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|</body>|<script async src=\"https://statjolt.com/measure/c.min.js\" data-user=\"YOUR_ID\"></script></body>|ni"
</Location>
</VirtualHost>
Reload Apache:
sudo systemctl reload apache2
mod_substitute can't change a compressed page. The RequestHeader line asks your app for an uncompressed page. AddOutputFilterByType keeps the change on HTML pages only.
Traefik needs the rewrite-body plugin. This version also handles compressed pages.
Add the plugin to your static config, for example traefik.yml:
experimental:
plugins:
rewrite-body:
moduleName: "github.com/packruler/rewrite-body"
version: "v1.1.0"
Add the router and the middleware to your dynamic config. In service, use the name of your existing service:
http:
routers:
app:
rule: "Host(`example.com`)"
service: app
middlewares:
- statjolt
middlewares:
statjolt:
plugin:
rewrite-body:
rewrites:
- regex: "</body>"
replacement: '<script async src="https://statjolt.com/measure/c.min.js" data-user="YOUR_ID"></script></body>'
Restart Traefik. It loads plugins only at start.
The plugin only changes HTML pages by default.
Your app sits behind your reverse proxy. Every page goes through the proxy first. The proxy finds the closing </body> tag in the page and puts the StatJolt code right in front of it.
Open your app in a private window. You see the StatJolt badge on the page. Click a few pages. Refresh your StatJolt dashboard and see your first visitor without waiting for the data.
Work through these steps in order.
1. Look for the code in the page. Open your app and press Ctrl+U to see the page source. Search for statjolt.
2. Check the Content-Security-Policy header. Some apps block scripts from other sites. Open the browser console with F12. Look for an error that names statjolt.com. If you see one, allow https://statjolt.com in script-src and connect-src. With End of the sidebar or Bottom of the footer, also allow 'unsafe-inline' in script-src.
3. Clear your caches. If your domain uses Cloudflare or another cache, clear it. Then open the page again in a private window.
Once you log in, everything is clickable. There are more tabs if you want to dig deeper. You can also click on a page to see which channels brought the most visitors there. Combine these with mobile, country or almost anything. You can easily delete any of these filters with simple close buttons on them.
| Name | Visits | Share | Change |
|---|---|---|---|
| 2,331 | +12.4% | ||
| direct | 1,140 | +4.1% | |
| pinterest.com | 596 | +31.8% | |
| facebook.com | 371 | -6.2% | |
| bing.com | 169 | +2.9% | |
| duckduckgo.com | 84 | 0.0% |
| Name | Visits | Share | Change |
|---|---|---|---|
| / | 2,732 | +9.7% | |
| /recipes | 1,495 | +18.2% | |
| /blog/starter-care | 1,167 | +6.4% | |
| /blog/sourdough-starter | 1,020 | +44.1% | |
| /recipes/bread | 787 | -2.3% | |
| /recipes/pizza-dough | 545 | +7.8% |
StatJolt covers the basics behind your reverse proxy: visitors, sources, pages and devices.
Plus! Included too:
StatJolt is a simple web analytics tool for self-hosted apps. The statistics are cookieless. So you don't need a cookie banner, because there is no personal data. You still get every number.
Use your reverse proxy. It adds the StatJolt code to every HTML page of the app. You don't touch the app itself.
Yes. Both serve normal HTML pages, so your reverse proxy can add the code to them. The same goes for other apps for hosting eBooks/audiobooks.
Yes. Build Caddy with the replace-response plugin. Then copy the config from the Caddy tab above.
A floating badge stays in its corner of the screen. With End of the sidebar the badge goes at the end of your page's <aside> element. With Bottom of the footer it goes at the end of your page's last <footer> element.
Yes. Many apps change the page without a full reload. StatJolt counts these page views too.
No. StatJolt sets no cookies. It collects no personal data.
No. The script is small. It never blocks the page from loading.
Just paste the code and see how much clearer it gets. No cookies, no consent tool. €0 until 11 April 2027 23:59:59, at any traffic level. Later, for small sites it still costs €0.
Get my free account