Skip to main content
Medusa → BigQueryIntegration guide

Connecting Medusa to BigQuery

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. BigQuery has no attribution model, no deduplication rules and no opinion about your data — which makes it the only destination on this site where every number is exactly as good as the query that produced it. The join between them succeeds or fails on one thing: whether whatever join key you decide on reaches the Medusa order before the conversion happens, because BigQuery can only match a conversion it can tie back to a click it recognizes.

Free30 minutesNo obligation

Specific to this pair

Medusa to BigQuery: you already own the database

Replicate Medusa's order, payment, refund and cart tables from Postgres into BigQuery, checking names for your version, and flatten metadata click IDs into staging columns. Build revenue from captured payments minus refunds, keyed on order ID. Replicas hold state, not events, so snapshot metadata at payment capture in case click IDs are rewritten.

Medusa runs on your own Postgres, so the question is not how to extract orders but what to replicate. Replicating the order, payment, refund and cart tables, or a change stream of them, gives BigQuery the full order history without going through an API; check the table names for your Medusa version, because the data model changed between major versions. Click IDs live in cart and order metadata as JSON, so flatten gclid, fbclid, ttclid and the rest into columns in a staging view instead of parsing JSON in every report.

Decide in SQL what counts. An order exists when the cart completes, but money exists at payment capture, and the gap between them holds every failed and pending payment. Build the revenue table from captured payments minus refunds, keyed on order ID, and keep placed-but-uncaptured orders visible as their own status rather than dropping them.

The trap specific to replicating Medusa: you get state, not events. If anything later edits an order's metadata, the original click ID is gone from the replica too. Either have your payment-capture subscriber write an append-only snapshot of the metadata at that moment, or make sure nothing ever rewrites those keys.

Medusa → BigQuery · what breaks

Why this join usually fails — Medusa → BigQuery

  1. 01

    Whatever join key you decide on never reaches Medusa

    The storefront is separate from the backend, and the identifier must be attached to the cart before the order is created.

  2. 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.

  3. 03

    The warehouse quietly disagreeing with every platform

    This is not a bug — it is the point. Your warehouse counts orders; Google counts click-attributed conversions in its window; Meta counts differently again. When the four numbers differ, the warehouse is usually right about revenue and wrong about attribution, and knowing which question you are answering is the whole skill.

  4. 04

    Nothing reconciles afterwards

    BigQuery will not tell you anything is wrong. Verify by querying the table directly against your source system's own totals, and check for duplicate rows on the join key before trusting any aggregate.

Medusa → BigQuery · the fix

What working looks like — Medusa → BigQuery

  • Whatever join key you decide on on every order

  • Conversions arriving in BigQuery

    The row lands in a table you own, joinable to every other table you own, with no window and no expiry.

  • Reconciled against the source

Medusa → BigQuery · architecture

How Medusa and BigQuery actually connect

  1. 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. 2

    BigQuery needs a click to match

    BigQuery needs a schema and consistent types. The failure mode is not rejection, it is silent divergence: a column that arrives as a string in one load and an integer in the next, or a timestamp in the wrong zone, which produces answers that look plausible and are not.

  3. 3

    The identifier is the bridge

    Whatever join key you decide on, captured at the visit and carried into the Medusa order.

  4. 4

    The event source decides reliability

    Send orders at payment capture, at the paid total.

  5. 5

    Deduplication at the destination

    Nothing deduplicates for you. Streaming inserts are at-least-once, so a retried load can create duplicate rows, and the only protection is a deduplication step you write and actually run.

Medusa → BigQuery · normal or broken

Working vs. broken, side by side — Medusa → BigQuery

Normal, not a fault

  • Whatever join key you decide on present on the order

  • Sent from a Medusa subscriber on order payment capture

  • Deduplicated correctly

    Nothing deduplicates for you. Streaming inserts are at-least-once, so a retried load can create duplicate rows, and the only protection is a deduplication step you write and actually run.

  • Reconciles with the source

Actually broken

  • Whatever join key you decide on 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

    This is not a bug — it is the point. Your warehouse counts orders; Google counts click-attributed conversions in its window; Meta counts differently again. When the four numbers differ, the warehouse is usually right about revenue and wrong about attribution, and knowing which question you are answering is the whole skill.

  • Nobody has reconciled it

Medusa → BigQuery · diagnose

Diagnostic order — Medusa → BigQuery

  1. 01

    Count orders carrying whatever join key you decide on

  2. 02

    Follow one real conversion end to end

  3. 03

    Check which event your subscriber listens to

    One line of code, and it decides whether you are counting orders or counting money.

  4. 04

    Reconcile warehouse order counts against each platform for one closed window

    The gaps localize the problem: a gap against all platforms is a collection issue, a gap against one is that platform's window or matching.

  5. 05

    Read the match rate, not the success message

    BigQuery will not tell you anything is wrong. Verify by querying the table directly against your source system's own totals, and check for duplicate rows on the join key before trusting any aggregate.

Medusa → BigQuery · prove

How it gets proven — Medusa → BigQuery

Source of truth

Medusa orders by payment status, emitted from your own subscriber code.

  • Whatever join key you decide on confirmed present on a live order.
  • Warehouse order counts and revenue reconciled against the source system for a fully closed window, with duplicates checked on the join key.
  • Payment-captured orders reconciled against imported conversions.

Medusa → BigQuery · free audit

What we check in the free audit

  • Count orders carrying whatever join key you decide on
  • Follow one real conversion end to end
  • Check which event your subscriber listens to
  • Reconcile warehouse order counts against each platform for one closed window
  • Read the match rate, not the success message

Checked against

Medusa orders by payment status, emitted from your own subscriber code.

Get my free conversion tracking audit

Free30 minutesNo obligation

Medusa → BigQuery · when not to buy

When you don't need this — Medusa → BigQuery

  • Measure identifier coverage yourself first — pull your last hundred orders and count how many carry whatever join key you decide on.
  • If every payment method you accept is instant, the two events nearly coincide and the distinction costs more than it returns.
  • If you have one store and one ad platform, a warehouse is infrastructure you will maintain for a reconciliation you could do in a spreadsheet.

Medusa → BigQuery · what we deliver

What gets built — Medusa → BigQuery

  • 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 BigQuery

    Streaming inserts or scheduled batch loads from your order system, with the raw event retained alongside whatever you derive from it.

  • 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.

Get my free conversion tracking audit

From $400 · See packages

FAQ

Medusa → BigQuery questions, answered

Replicate the relevant Postgres tables or a change stream, then flatten the click IDs from cart and order metadata in a staging view.

Free · 30 min

Get Medusa and BigQuery joined properly

Free30 minutesNo obligation