Source: https://datafa.st/docs/managed-proxy
Markdown source: https://datafa.st/docs/managed-proxy.md
Description: Route the DataFast script through your own subdomain with no server code — add a DNS record, update your script tag, and bypass ad blockers.

# Managed reverse proxy

Route DataFast analytics through a subdomain you control without running proxy code. DataFast handles the routing, SSL certificate, and event collection for you.

> **Recommended for most sites.** Use the managed proxy unless you already have a self-hosted proxy setup in your app or web server. See the [proxy setup guide](/docs/proxy-guide) to compare both options.

## Why use a proxy?

Ad blockers often block known analytics domains. A first-party subdomain on your own domain is less likely to be blocked, which can improve analytics accuracy and [revenue attribution](/docs/revenue-attribution-guide).

You do not need a proxy to start using DataFast. Add it before production, before a launch, or when you want more complete data from ad-blocking visitors.

Without a proxy, your website loads the script and sends events to `datafa.st`. With managed proxy, those requests go through your own subdomain instead, such as `a.yourdomain.com/js/script.js` and `a.yourdomain.com/api/events`, while DataFast still handles routing and SSL.

## 1. Enable managed proxy

1. Open [Website settings -> General](/dashboard#managed-proxy)
2. Find **Managed Proxy**
3. Enter a neutral subdomain such as `a.yourdomain.com`
4. Click **Enable**

> Pick a short, neutral subdomain that does not describe analytics. Good examples include `a.yourdomain.com` or `cdn.yourdomain.com`. Avoid names like `analytics.yourdomain.com` or `tracking.yourdomain.com` because blocklists may target them. Use a subdomain, not your main site hostname.

If you are signed in, the docs website selector updates the dashboard link to the selected website.

## 2. Add DNS records

After enabling the proxy, DataFast shows the exact DNS records to add at your DNS provider. For a normal subdomain, add a CNAME record:

| DNS field | Value |
|---|---|
| Type | CNAME |
| Name / Host | `a` |
| Target / Value | `proxy.datafast.io` |

> `a` is only an example. If you chose `cdn.yourdomain.com`, the name/host is `cdn`.

If DataFast shows a TXT verification record, add it too. This can happen when the domain needs ownership verification. You can remove the TXT record after the proxy status becomes **Active**.

DNS propagation usually takes 1–10 minutes. SSL is issued automatically once DNS is correct. Click **Check status** in settings until the badge shows **Active**.

## 3. Update your tracking script

Replace the default DataFast script with a single proxied script tag. The important parts are:

- `src` loads the script from your proxy subdomain.
- `data-api-url` sends events to the same proxy subdomain.
- `data-domain` stays your real website domain, not the proxy subdomain.

```html
<script
  defer
  data-website-id="dfid_******"
  data-domain="yourdomain.com"
  data-api-url="https://a.yourdomain.com/api/events"
  src="https://a.yourdomain.com/js/script.js"
></script>
```

Use the same proxy hostname in both `src` and `data-api-url`. Do not use a relative `data-api-url` for managed proxy, because relative URLs are resolved against the page hostname, not the script hostname.

For local development, add `data-allow-localhost="true"` and keep `data-api-url` pointed at your live proxy host.

## Verify the setup

1. Visit your live website, not the proxy subdomain root
2. Open the browser Network tab
3. Confirm `script.js` loads from your proxy host, for example `a.yourdomain.com`
4. Confirm event requests go to `https://a.yourdomain.com/api/events`
5. Check that new visits appear in DataFast

## Troubleshooting

### Status stays pending

- Confirm the CNAME matches the values shown in the dashboard
- Make sure the record is a DNS record, not a URL redirect or forwarding rule
- If your DNS provider has a proxy mode, disable it for this CNAME while DataFast provisions SSL
- Wait a few more minutes, then click **Check status**

### Status shows error

- Re-check the record type, host/name, and target/value
- Add the TXT verification record if DataFast shows one
- Confirm you are configuring the DNS zone for the root domain, such as `yourdomain.com`

### Analytics still blocked or not loading

- Avoid obvious subdomains such as `analytics`, `tracking`, `metrics`, or `datafast`
- Make sure the script uses `https://` and your proxy subdomain, not `datafa.st`
- Confirm `data-domain` is your real site domain
- If you use a Content Security Policy, allow `script-src` and `connect-src` for your proxy hostname

### Events go to your main site or localhost

This means `data-api-url` is missing or relative. Set it to the full proxy URL:

```html
data-api-url="https://a.yourdomain.com/api/events"
```

## Remove managed proxy

In **Website settings -> General -> Managed Proxy**, click **Remove**. Then delete the DNS records at your DNS provider and change your script `src` back to `https://datafa.st/js/script.js`.

## Compare setup options

| | Managed proxy | Self-hosted proxy |
|---|---|---|
| Best for | Most sites | Apps that already proxy requests through their own server |
| Code required | No | Yes |
| DNS required | Yes, CNAME | Optional |
| SSL | Automatic | Depends on your host |
| Tracking script | Full proxy URLs for script and events | Same-origin paths such as `/js/script.js` and `/api/events` |
| Maintenance | Handled by DataFast | Handled by your app/server |

See the [proxy setup guide](/docs/proxy-guide) for self-hosted options.
