Configure an Nginx Reverse Proxy for First-Party Web Analytics
Copy-paste Nginx proxy_pass configuration to serve your analytics script from a first-party path and avoid client-side ad blocker lists.
Add this to nginx.conf. Replace /_ds with a path of your own.
nginx.conf
location = /_ds/js/script.cookies.js {
proxy_pass https://usedataowl.com/js/script.cookies.js;
proxy_set_header Host usedataowl.com;
proxy_ssl_server_name on;
}
location = /_ds/api/e {
proxy_pass https://usedataowl.com/api/e;
proxy_set_header Host usedataowl.com;
proxy_set_header X-DataOwl-IP $remote_addr;
proxy_set_header Cookie "";
proxy_ssl_server_name on;
}
# Revenue attribution: payment links and datasense("payment", { email })
location = /_ds/api/p {
proxy_pass https://usedataowl.com/api/p;
proxy_set_header Host usedataowl.com;
proxy_set_header Cookie "";
proxy_ssl_server_name on;
}
# Session replay, if you turn it on
location = /_ds/js/recorder.js {
proxy_pass https://usedataowl.com/js/recorder.js;
proxy_set_header Host usedataowl.com;
proxy_ssl_server_name on;
}
location = /_ds/api/replay {
proxy_pass https://usedataowl.com/api/replay;
proxy_set_header Host usedataowl.com;
proxy_set_header X-DataOwl-IP $remote_addr;
proxy_set_header Cookie "";
proxy_ssl_server_name on;
client_max_body_size 10m;
}
# Forms, if you create any
location = /_ds/js/forms.js {
proxy_pass https://usedataowl.com/js/forms.js;
proxy_set_header Host usedataowl.com;
proxy_ssl_server_name on;
}
location = /_ds/api/forms {
proxy_pass https://usedataowl.com/api/forms;
proxy_set_header Host usedataowl.com;
proxy_set_header Cookie "";
proxy_ssl_server_name on;
}Then load the script from your own domain:
html
<script
defer
data-website-id="YOUR_SITE_ID"
src="/_ds/js/script.cookies.js"
></script>Verify
Open your site with an ad blocker on. In the browser's network tab, /_ds/js/script.cookies.js and /_ds/api/e load from your own domain, and the visit shows up on the Realtime page.