---
title: "Vercel | Using a proxy | Documentation - Vemetric"
description: "Optimize tracking by proxying data via Vercel."
url: https://vemetric.com/docs/advanced-guides/using-a-proxy/vercel
---

# Setting up a proxy using Vercel

Optimize tracking by proxying data via Vercel.

* * *

If you’re using Vercel, it’s quite easy to proxy the traffic through your own domain, checkout the guide below.

## Setup

### Vercel Configuration

First you have to add two rewrite rules and matching response headers to your `vercel.json` file.

```json
{
  "headers": [
    {
      "source": "/_v_script.js",
      "headers": [
        {
          "key": "X-Robots-Tag",
          "value": "noindex, nofollow"
        }
      ]
    },
    {
      "source": "/_v/:slug",
      "headers": [
        {
          "key": "X-Robots-Tag",
          "value": "noindex, nofollow"
        }
      ]
    }
  ],
  "rewrites": [
    {
      "source": "/_v_script.js",
      "destination": "https://cdn.vemetric.com/main.js"
    },
    {
      "source": "/_v/:slug",
      "destination": "https://hub.vemetric.com/:slug"
    }
  ]
}
```

### Configure Vemetric

Depending on your setup you need to adjust the Vemetric configuration:

**HTML**

The `src` attribute of the script tag should now point to `/_v_script.js`. You also need to pass the `data-host` attribute with the value of `/_v`

```html
<script>
  window.vmtrcq = window.vmtrcq || [];
  window.vmtrc = window.vmtrc || function (){window.vmtrcq.push(Array.prototype.slice.call(arguments))};
</script>
<script defer src="/_v_script.js" data-host="/_v" id="vmtrc-scr" data-token="YOUR_PROJECT_TOKEN"></script>
```

**JavaScript**

For the JavaScript SDK, you need to pass the `scriptUrl` and `host` options to the `init` function with the value of your proxy domain.

```ts
import { vemetric } from '@vemetric/web';

vemetric.init({
  token: 'YOUR_PROJECT_TOKEN',
  scriptUrl: '/_v_script.js',
  host: '/_v',
});
```

**React**

For the React SDK, you need to pass the `scriptUrl` and `host` props to the `VemetricScript` component with the value of your proxy domain.

```tsx
import { VemetricScript } from '@vemetric/react';

<VemetricScript
  token="YOUR_PROJECT_TOKEN"
  scriptUrl="/_v_script.js"
  host="/_v"
/>
```

**Astro**

For the Astro SDK, you need to pass the `scriptUrl` and `host` props to the `VemetricScript` component with the value of your proxy domain.

```tsx
import { VemetricScript } from '@vemetric/astro';

<VemetricScript
  token="YOUR_PROJECT_TOKEN"
  scriptUrl="/_v_script.js"
  host="/_v"
/>
```

Congratulations! You’ve successfully set up a proxy using Vercel. Please reach out if you have any questions.
