Source: https://usedataowl.com/docs/netlify-proxy
Markdown source: https://usedataowl.com/docs/netlify-proxy.md
Description: Add redirects to netlify.toml to proxy web analytics through your own domain for more complete visitor and conversion tracking.

# Set Up a First-Party Web Analytics Proxy on Netlify

Add this to `netlify.toml`. Replace `/_ds` with a path of your own.

```toml title="netlify.toml"
[[redirects]]
  from = "/_ds/js/script.cookies.js"
  to = "https://usedataowl.com/js/script.cookies.js"
  status = 200
  force = true

[[redirects]]
  from = "/_ds/api/e"
  to = "https://usedataowl.com/api/e"
  status = 200
  force = true

[[redirects]]
  from = "/_ds/api/p"
  to = "https://usedataowl.com/api/p"
  status = 200
  force = true

# Session replay, if you turn it on
[[redirects]]
  from = "/_ds/js/recorder.js"
  to = "https://usedataowl.com/js/recorder.js"
  status = 200
  force = true

[[redirects]]
  from = "/_ds/api/replay"
  to = "https://usedataowl.com/api/replay"
  status = 200
  force = true

# Forms, if you create any
[[redirects]]
  from = "/_ds/js/forms.js"
  to = "https://usedataowl.com/js/forms.js"
  status = 200
  force = true

[[redirects]]
  from = "/_ds/api/forms"
  to = "https://usedataowl.com/api/forms"
  status = 200
  force = true
```

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.
