Connecting Medusa to GA4
Medusa is a Node commerce engine you extend in your own codebase, which makes the conversion event a piece of application code — and therefore something that can be tested rather than hoped for. 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 Medusa order 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
Medusa to GA4: purchase from the payment subscriber, once
Have the storefront write client_id and session_id from the _ga cookies into Medusa cart metadata, then send purchase from the payment-capture subscriber through Measurement Protocol with the order ID as transaction_id and line items. Remove the confirmation-page purchase tag, since GA4 won't dedupe them, and send refunds with the same transaction_id.
Because Medusa conversions are your own code, GA4's purchase can be sent from the subscriber that handles payment capture, through Measurement Protocol, with the order's ID as transaction_id. For that event to join the shopper's session, the storefront has to read client_id and session_id from the _ga cookies and write them into cart metadata alongside any click IDs. A subscriber running on the backend has no browser cookies of its own.
Then remove the purchase tag from the storefront's order confirmation page, or keep it and drop the server event; GA4 does not deduplicate Measurement Protocol against browser events. Pick one and enforce it. Server-side is usually the better choice for Medusa because it fires on captured payment, while the confirmation page fires on every order placed, including ones whose payment later fails.
Watch the timing if you authorize at checkout and capture at fulfilment. Measurement Protocol only accepts timestamps a short way into the past (72 hours at the time of writing), and the original session will have ended, so a capture days later lands on the user rather than the session; check how your property reports it. Send refunds from Medusa's refund handling as a GA4 refund event with the same transaction_id, and populate items from the order's line items so product reports keep working once the browser tag is gone.
Medusa → GA4 · what breaks
Why this join usually fails — Medusa → GA4
- 01
The GA4 client_id never reaches Medusa
The storefront is separate from the backend, and the identifier must be attached to the cart before the order is created.
- 02
Firing on order placed rather than payment captured
They are different events and the gap between them contains every failed and pending payment. Order-placed is the easier hook and the wrong one.
- 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.
Medusa → GA4 · the fix
What working looks like — Medusa → GA4
The GA4 client_id on every order
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
Medusa → GA4 · architecture
How Medusa and GA4 actually connect
- 1
Medusa holds the truth
Because you own the event handlers, the conversion can fire from the payment-captured event specifically rather than from whatever the frontend happened to render.
- 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 Medusa order.
- 4
The event source decides reliability
Send orders at payment capture, at the paid total.
- 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.
Medusa → GA4 · normal or broken
Working vs. broken, side by side — Medusa → GA4
Normal, not a fault
The GA4 client_id present on the order
Sent from a Medusa subscriber on order payment capture
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
The storefront is separate from the backend, and the identifier must be attached to the cart before the order is created.
Sent from the browser
They are different events and the gap between them contains every failed and pending payment. Order-placed is the easier hook and the wrong one.
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
Medusa → GA4 · diagnose
Diagnostic order — Medusa → GA4
- 01
Count orders carrying the GA4 client_id
- 02
Follow one real conversion end to end
- 03
Check which event your subscriber listens to
One line of code, and it decides whether you are counting orders or counting money.
- 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.
Medusa → GA4 · prove
How it gets proven — Medusa → GA4
Source of truth
Medusa orders by payment status, emitted from your own subscriber code.
- The GA4 client_id confirmed present on a live order.
- Server events confirmed in DebugView attaching to an existing session with the original traffic source intact.
- Payment-captured orders reconciled against imported conversions.
Medusa → GA4 · free audit
What we check in the free audit
- Count orders carrying the GA4 client_id
- Follow one real conversion end to end
- Check which event your subscriber listens to
- Check whether server events carry a session and a source
- Read the match rate, not the success message
Checked against
Medusa orders by payment status, emitted from your own subscriber code.
Free30 minutesNo obligation
Medusa → GA4 · when not to buy
When you don't need this — Medusa → GA4
- Measure identifier coverage yourself first — pull your last hundred orders and count how many carry the GA4 client_id.
- If every payment method you accept is instant, the two events nearly coincide and the distinction costs more than it returns.
- 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.
Medusa → GA4 · what we deliver
What gets built — Medusa → GA4
Identifier capture into Medusa
Write the identifier into cart metadata at first touch so it is carried onto the order automatically at completion.
Event source: a Medusa subscriber on order payment capture
Send orders at payment capture, at the paid total.
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
Refunds emit their own event and should reverse.
Written guarantee
95%+ tracking accuracy
Measured against Medusa orders by payment status, emitted from your own subscriber code.. Miss it and we keep working at no cost.
From $400 · See packages
FAQ
Medusa → GA4 questions, answered
From the backend subscriber on payment capture, with client_id and session_id carried in cart metadata, and not from both. GA4 counts browser and Measurement Protocol purchases twice.
The Measurement Protocol event was sent without the shopper's client_id. Write it into cart metadata from the storefront before the order is created.
Almost always because the GA4 client_id never reached the Medusa order. The storefront is separate from the backend, and the identifier must be attached to the cart before the order is created. 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.
A Medusa subscriber on order payment capture. Send orders at payment capture, at the paid total.
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 Medusa → GA4
- Stripe → GA4Connecting Stripe to GA4
- PayPal → GA4Connecting PayPal to GA4
- HubSpot → GA4Connecting HubSpot to GA4
RELATED GUIDES
Where Medusa → GA4 fits in the rest of your tracking
- Gumroad → GA4Connecting Gumroad to GA4
- EDD → GA4Connecting Easy Digital Downloads to GA4
- Saleor → GA4Connecting Saleor to GA4
- Medusa → PostHogConnecting Medusa to PostHog
- Medusa → MixpanelConnecting Medusa to Mixpanel
- Jewelry ecommerceConversion tracking for jewelry ecommerce, measured in settled orders
- Shopify POS → GA4Connecting Shopify POS to GA4
- Swell → GA4Connecting Swell to GA4
Free · 30 min
Get Medusa and GA4 joined properly
Free30 minutesNo obligation
