Connecting Supabase Auth to GA4
Supabase Auth sits directly on your own Postgres database, which means the identity and the revenue can be joined with a query rather than through an integration. GA4 is where the business goes to understand what happened, which makes an unattributed conversion there expensive in decisions rather than in ad spend. The join between them succeeds or fails on one thing: whether the GA4 client_id reaches the Supabase user before the conversion happens, because GA4 can only match a conversion it can tie back to a click it recognizes.
Free30 minutesNo obligation
Specific to this pair
Supabase Auth to GA4: client_id and user_id in one row
Write the GA4 client_id from the _ga cookie onto the Supabase profile row at first login, reading it on your marketing domain before OAuth redirects, and use the auth UUID as user_id. Send purchase through the Measurement Protocol from a Database Webhook or scheduled query on billing, with the subscription or order ID as transaction_id. Avoid also firing purchase in-browser.
Write the GA4 client_id from the _ga cookie onto the user's profile row at first login, next to the auth user ID, and every later paid conversion can be sent with both. Use the Supabase user UUID as GA4 user_id, never the email, and set it in the browser after login too, so server events and browser sessions resolve to the same user.
OAuth is where the client_id goes missing. signInWithOAuth sends the visitor to the provider and back through your Supabase project's callback, and if your marketing site and app are on different domains, the _gl linker parameter does not survive that round trip. Read the _ga cookie on your marketing domain before the redirect, persist it, and write it to the profile at the first authenticated request. A trigger on auth.users can create the profile row, but the client_id itself has to come from the browser.
Then send purchase from a scheduled query or a Database Webhook on your billing table, with the subscription or order ID as transaction_id and the stored client_id. Measurement Protocol does not deduplicate, so if your checkout's success page also fires purchase, pick one side. Renewals can go as purchase with their own transaction IDs, and first-user reports keep crediting them to the original acquisition source.
Supabase Auth → GA4 · what breaks
Why this join usually fails — Supabase Auth → GA4
- 01
The GA4 client_id never reaches Supabase Auth
OAuth flows redirect off-site and back, which can lose an identifier captured before login.
- 02
Building a pipeline for a join you could write in SQL
Teams reach for a CDP or an event pipeline to connect identity to revenue when both tables sit in the same database. The simplest correct answer is usually a scheduled query.
- 03
Everything lands under (direct)/(none)
The classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.
- 04
Nothing reconciles afterwards
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
Supabase Auth → GA4 · the fix
What working looks like — Supabase Auth → GA4
The GA4 client_id on every account
Conversions arriving in GA4
Conversions appear in GA4 attributed to the original session's source and medium, so acquisition reporting reflects what actually drove revenue.
Reconciled against the source
Supabase Auth → GA4 · architecture
How Supabase Auth and GA4 actually connect
- 1
Supabase Auth holds the truth
Because everything is in one Postgres instance, the join that most products build a pipeline for is a SQL statement here. That is a genuine advantage and it is frequently unused.
- 2
GA4 needs a click to match
GA4 needs the client_id to attach a server event to the user and session that produced the click. Without it there is no attribution to inherit and the event is orphaned.
- 3
The identifier is the bridge
The GA4 client_id, captured at the visit and carried into the Supabase user.
- 4
The event source decides reliability
Send paid conversions from a query joining auth users to billing.
- 5
Deduplication at the destination
GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.
Supabase Auth → GA4 · normal or broken
Working vs. broken, side by side — Supabase Auth → GA4
Normal, not a fault
The GA4 client_id present on the account
Sent from your own database
Deduplicated correctly
GA4 has no built-in deduplication for Measurement Protocol. If the browser also sends the event, it counts twice. The only reliable approach is to decide per event which side sends it, and enforce that decision — GA4 will not protect you from your own duplicates.
Reconciles with the source
Actually broken
The GA4 client_id missing on most records
OAuth flows redirect off-site and back, which can lose an identifier captured before login.
Sent from the browser
Teams reach for a CDP or an event pipeline to connect identity to revenue when both tables sit in the same database. The simplest correct answer is usually a scheduled query.
Counted twice, or not at all
The classic Measurement Protocol symptom, and it always means the same thing: the client_id was missing or wrong, so GA4 had no session to attach the event to and invented a new user.
Nobody has reconciled it
Supabase Auth → GA4 · diagnose
Diagnostic order — Supabase Auth → GA4
- 01
Count accounts carrying the GA4 client_id
- 02
Follow one real conversion end to end
- 03
Check whether identity and billing are in the same database
If they are, most of the usual integration complexity is unnecessary.
- 04
Check whether server events carry a session and a source
In GA4 Realtime or DebugView, find the event and look at its session and traffic source. A brand-new user with no source on every server event is the missing-client_id signature.
- 05
Read the match rate, not the success message
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
Supabase Auth → GA4 · prove
How it gets proven — Supabase Auth → GA4
Source of truth
Your own database, joining the auth user to the subscription or order table.
- The GA4 client_id confirmed present on a live account.
- Server events confirmed in DebugView attaching to an existing session with the original traffic source intact.
- Paid conversions reconciled by query against imported conversions, with identifier survival verified across OAuth.
Supabase Auth → GA4 · free audit
What we check in the free audit
- Count accounts carrying the GA4 client_id
- Follow one real conversion end to end
- Check whether identity and billing are in the same database
- Check whether server events carry a session and a source
- Read the match rate, not the success message
Checked against
Your own database, joining the auth user to the subscription or order table.
Free30 minutesNo obligation
Supabase Auth → GA4 · when not to buy
When you don't need this — Supabase Auth → GA4
- Measure identifier coverage yourself first — pull your last hundred accounts and count how many carry the GA4 client_id.
- If billing lives in a separate system, the join is a real integration again and the advantage disappears.
- GA4 is reporting, not bidding. If your problem is ad platform optimization, fix the ad platform destination first — GA4 will not change what any campaign does.
Supabase Auth → GA4 · what we deliver
What gets built — Supabase Auth → GA4
Identifier capture into Supabase Auth
Persist the identifier before the OAuth redirect and write it onto the user row at first login, where it is then permanently queryable.
Event source: your own database
Send paid conversions from a query joining auth users to billing.
Dispatch to GA4
Measurement Protocol events with the client_id, session_id and the correct measurement ID and API secret, sent server-side.
Reversals where they exist
Cancellations reverse against the same user row.
Written guarantee
95%+ tracking accuracy
Measured against Your own database, joining the auth user to the subscription or order table.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Supabase Auth → GA4 questions, answered
Store the GA4 client_id on the user row at first login and send purchase by Measurement Protocol from a query joining auth users to billing. Use the subscription or order ID as transaction_id.
OAuth redirects and cross-domain hops drop the client_id. Capture it before the redirect and write it onto the user row at first login.
Almost always because the GA4 client_id never reached the Supabase user. OAuth flows redirect off-site and back, which can lose an identifier captured before login. Measure coverage before debugging the dispatch.
The client_id, from the _ga cookie. Measurement Protocol events without it are rejected or create a brand-new user with no session and no source, which is how server events end up filed under (direct)/(none) and make paid channels look worse than they are. Send session_id alongside it so the event joins the existing session, and include engagement_time_msec or the event may not appear as expected in reports.
Your own database. Send paid conversions from a query joining auth users to billing.
GA4 DebugView shows events arriving with their parameters, and Realtime confirms the user and session they attached to. Neither tells you whether you are double-counting — for that, compare GA4's conversion count against the source system's record for the same window.
More on Supabase Auth → GA4
- Firebase Auth → GA4Connecting Firebase Authentication to GA4
- Supabase Auth → Google AdsConnecting Supabase Auth to Google Ads
- Supabase Auth → MetaConnecting Supabase Auth to Meta Conversions API
RELATED GUIDES
Where Supabase Auth → GA4 fits in the rest of your tracking
- Auth0 → GA4Connecting Auth0 to GA4
- Okta → GA4Connecting Okta to GA4
- Clerk → GA4Connecting Clerk to GA4
- Supabase Auth → AmplitudeConnecting Supabase Auth to Amplitude
- Supabase Auth → PostHogConnecting Supabase Auth to PostHog
- SaaSConversion tracking for SaaS, from signup through to the payment that matters
- Firebase Auth → GA4Connecting Firebase Authentication to GA4
Free · 30 min
Get Supabase Auth and GA4 joined properly
Free30 minutesNo obligation
