Reverse proxy starter for tracking AI agent visits on Framer or Webflow sites when the custom domain is managed through Netlify DNS.
visitor or agent
-> Netlify DNS custom domain
-> Netlify Edge Function
-> Framer/Webflow origin
-> Sapient Agent Analytics
This is a reverse proxy, not a browser redirect. The visitor stays on your custom domain while Netlify fetches the Framer or Webflow origin behind the scenes.
-
Deploy this repo as a Netlify site.
-
Add your test custom domain to the Netlify site, for example:
agent-test.example.com -
Set these Netlify environment variables:
SAPIENT_API_KEY=sap_... ORIGIN_URL=https://your-site.framer.website SITE_PROVIDER=framer SAPIENT_TRACKING_SOURCE=netlify_edge_proxy
For Webflow:
ORIGIN_URL=https://your-site.webflow.io SITE_PROVIDER=webflow
-
Redeploy after changing environment variables.
-
Point the domain at the Netlify site.
| Variable | Required | Example | Notes |
|---|---|---|---|
SAPIENT_API_KEY |
Yes | sap_... |
Agent Analytics tracking key. |
ORIGIN_URL |
Yes | https://your-site.framer.website |
Framer/Webflow platform origin. Do not use your custom domain here. |
SITE_PROVIDER |
Recommended | framer or webflow |
Used to segment analytics by platform. |
SAPIENT_TRACKING_SOURCE |
Recommended | netlify_edge_proxy |
Identifies this traffic as Netlify Edge proxy traffic. |
If your apex domain is currently managed by another DNS provider and you want to test Netlify DNS without moving the whole domain, delegate a subdomain:
-
In Netlify, add a DNS zone or standalone delegated subdomain for:
agent-test.example.com -
Netlify will show nameservers for the delegated subdomain.
-
In your current DNS provider, add one
NSrecord for each Netlify nameserver:Type: NS Name: agent-test Target: <netlify-nameserver> -
Add
agent-test.example.comto this Netlify site under Domain management. -
Wait for DNS and certificate provisioning.
dig NS agent-test.example.com +short
curl -I https://agent-test.example.com/
curl -A "Mozilla/5.0 (compatible; GPTBot/1.0)" \
-H "Accept: text/html" \
https://agent-test.example.com/Then check Sapient Agent Analytics for events under agent-test.example.com.
Analytics is scheduled in the background with context.waitUntil(). If Sapient tracking fails or times out, the proxied page still renders.
The proxy only returns an error response when:
ORIGIN_URLis missing or invalid.ORIGIN_URLpoints back to the same host as the proxy, which would create a loop.- The Framer/Webflow origin cannot be reached.