Nginx proxy
Why a proxy? It loads the PureMetrix script and sends its data via your own domain, so ad blockers block it less often. Here is how to set it up with Nginx.
What you configure
Template reference: adapters/proxy/nginx.conf.
Copy the location /px/ proxy_pass blocks from adapters/proxy/nginx.conf. Preserve X-Forwarded-For.
Reload nginx and check the Network tab in your browser.
What the snippet looks like
<script defer data-domain="example.com" data-key="YOUR_PUBLIC_KEY"
src="https://www.example.com/px/js/script.js"></script> Copy your public key in PureMetrix under Site settings → General. Once the proxy works, pageviews appear as usual in app.puremetrix.org.
Troubleshooting
- Error 403 or 404 on
/px: a firewall is blocking the path, or the rewrite rule is missing. - Requests are sent but no stats appear: check that the public key and domain match your Site settings.
- Wrong country or city: make sure
X-Forwarded-For(the visitor’s original IP address) is passed on exactly once.