Source: https://usedataowl.com/docs/vercel-proxy
Markdown source: https://usedataowl.com/docs/vercel-proxy.md
Description: Add a few rewrite rules to vercel.json to route analytics requests through your own domain and prevent ad blockers from dropping visitors.

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

Add this to `vercel.json`. Replace `/_ds` with a path of your own.

```json title="vercel.json"
{
  "rewrites": [
    { "source": "/_ds/js/script.cookies.js", "destination": "https://usedataowl.com/js/script.cookies.js" },
    { "source": "/_ds/api/e", "destination": "https://usedataowl.com/api/e" },
    { "source": "/_ds/api/p", "destination": "https://usedataowl.com/api/p" },
    { "source": "/_ds/js/recorder.js", "destination": "https://usedataowl.com/js/recorder.js" },
    { "source": "/_ds/api/replay", "destination": "https://usedataowl.com/api/replay" },
    { "source": "/_ds/js/forms.js", "destination": "https://usedataowl.com/js/forms.js" },
    { "source": "/_ds/api/forms", "destination": "https://usedataowl.com/api/forms" }
  ]
}
```

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.
