---
title: "Install DataPocket on NGINX"
description: "Add DataPocket web analytics with revenue attribution to NGINX. Two location blocks in your server config."
url: "https://datapocket.vo1d.studio/docs/nginx"
lang: "en"
updated: "2026-11-13"
---

# Install DataPocket on NGINX

Two location blocks in your server config. Replace `YOUR_SITE_ID` and `YOUR_DOMAIN` with the values from your site's Install page. This guide serves the script from your own domain, so ad blockers can't tell it apart from your own code.

## Steps

1. Inside your server { } block:

```nginx
location ~ ^/dp/js/(script(\.[a-z]+)?(@\d+\.\d+\.\d+)?\.js)$ {
    proxy_pass https://datapocket.vo1d.studio/js/$1;
    proxy_set_header Host datapocket.vo1d.studio;
    proxy_set_header Cookie "";
    proxy_set_header Authorization "";
    proxy_ssl_server_name on;
    proxy_hide_header Set-Cookie;
}

location = /dp/api/event {
    proxy_pass https://datapocket.vo1d.studio/api/event;
    proxy_set_header Host datapocket.vo1d.studio;
    proxy_set_header X-Forwarded-For $remote_addr;
    # proxy_pass forwards every request header: drop the visitor's cookies and credentials
    proxy_set_header Cookie "";
    proxy_set_header Authorization "";
    proxy_ssl_server_name on;
    proxy_hide_header Set-Cookie;
}
```

2. Reload (nginx -t && nginx -s reload), then:

```html
<script
  defer
  data-site-id="YOUR_SITE_ID"
  data-domain="YOUR_DOMAIN"
  src="/dp/js/script.js"
></script>
```

3. Behind Cloudflare or a load balancer? Enable the realip module (set_real_ip_from + real_ip_header X-Forwarded-For) so $remote_addr is the visitor's IP.

## Verify

1. Deploy or publish, then open your site in a normal browser window (ad blockers off).
2. In the browser's Network tab, look for a POST to `/api/event` (or `/dp/api/event` when proxied) that returns `{"ok":true}`.
3. The DataPocket Install page for this site switches to "Receiving data" within a few seconds.

## Related guides

- [React Router](https://datapocket.vo1d.studio/docs/react-router): Framework mode (Remix) and library mode. pushState navigations are tracked automatically.
- [Vue.js](https://datapocket.vo1d.studio/docs/vue): Vue 3 + Vue Router, Nuxt, Vite. History-mode routing is tracked automatically.
- [JavaScript apps](https://datapocket.vo1d.studio/docs/npm): React, Vue, Svelte or Angular: the script tag with typed calls, plus server-side payments and goals over HTTP.
- [Express](https://datapocket.vo1d.studio/docs/express): Serve the script and forward events from your Express server.
- [AI crawler tracking](https://datapocket.vo1d.studio/docs/ai-bots)
