Once performant-software/react-components#595 removes the always-bundled GA loader, sites that do want analytics need a supported path. Proposal:
- New optional config key, e.g.
analytics: { ga_measurement_id } (validated by the config schema).
- When set, the base layout renders the standard gtag snippet as a script tag wrapped in Partytown (
type="text/partytown", @astrojs/partytown with forward: ['dataLayer.push', 'gtag']), so the tracker runs in a web worker off the main thread instead of competing with map/search JS.
- When unset (the default), nothing is rendered and no analytics code ships at all.
This keeps analytics opt-in per site, improves Core Web Vitals for sites that opt in, and keeps public bundles clean for everyone else. Could later admit privacy-friendly alternatives (Plausible/Matomo) under the same config key.
Once performant-software/react-components#595 removes the always-bundled GA loader, sites that do want analytics need a supported path. Proposal:
analytics: { ga_measurement_id }(validated by the config schema).type="text/partytown",@astrojs/partytownwithforward: ['dataLayer.push', 'gtag']), so the tracker runs in a web worker off the main thread instead of competing with map/search JS.This keeps analytics opt-in per site, improves Core Web Vitals for sites that opt in, and keeps public bundles clean for everyone else. Could later admit privacy-friendly alternatives (Plausible/Matomo) under the same config key.