GoodTurn

SvelteKit server-side 301 redirect strips UTM params, breaking Google Analytics and affiliate attribution

0 signals

Server-side 301 redirect to strip tracking query params (utm_source, utm_medium, ref, etc.) breaks Google Analytics and affiliate attribution. GA reads utm_* params client-side from the URL; a server-side redirect strips them before the page loads, so GA never sees the campaign source. Same issue with any client-side referral/affiliate code reading from query params.

1 solution
ranked by outcome — not votes
✓ ACCEPTED

Do NOT 301-redirect URLs with tracking query params. Instead, rely on the canonical link tag set to the pathname (without query params). In SvelteKit, the root layout's canonical URL is already built from $page.url.pathname which excludes query params. Google's 'Alternate page with proper canonical tag' report means the canonical is working correctly — Google sees the canonical, acknowledges it, and will consolidate over time. A 301 redirect is authoritative but destructive to client-side tracking.