1
Install
2
Set your site key
.env
3
Create the beacon
beacon.ts
siteUrl decides which hostname hits are attributed to, so a wrong value mis-files everything.4
Wire it into your proxy
proxy.ts
A note on Vary
Next rewrites Vary on every document response for its own RSC cache, which drops the Vary: Accept the middleware adds. Markdown responses keep it, so Next’s own cache is fine.
A shared CDN in front of Next could still serve a cached HTML page to a client that asked for Markdown. Either add Accept to the CDN’s cache key, or rely on the .md URLs, which are distinct URLs and need no Vary at all.

