Skip to main content
SendGrid → BigQueryIntegration guide

Connecting SendGrid to BigQuery

SendGrid carries both transactional and marketing mail through one account, which is convenient operationally and the source of the measurement problem: only one of those two streams has anything to do with acquisition. 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 SendGrid send 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

SendGrid events in BigQuery: joining email clicks to orders

Point SendGrid's Event Webhook at an endpoint writing to BigQuery, keeping recipient, sg_message_id, event type, timestamp, URL, category and custom arguments such as campaign and customer ID. Deduplicate on sg_event_id, join to orders on the customer ID, and partition by event date. Count marketing-category clicks, not opens, as touches, comparing with and without transactional clicks.

BigQuery is the cleanest place to settle what SendGrid email is worth, because it can hold the send log and the order log side by side. Point the Event Webhook at an endpoint that writes to BigQuery and keep every field: recipient, sg_message_id, event type, timestamp, URL clicked, category, and any custom arguments you attached, including a campaign ID and your customer ID.

Two keys do the work. sg_event_id identifies each webhook event, and the webhook can deliver the same event more than once, so deduplicate on it before counting anything. The customer ID, passed as a custom argument, joins email events to orders; an email address works too, but breaks when customers change addresses. Partition the events table by event date, because webhook volume on a large list grows quickly.

The query that answers the channel question: orders whose customer clicked a marketing-category email within your chosen window before ordering, excluding clicks in transactional categories. Run it with and without transactional clicks and the gap shows how much a pooled report was crediting receipts to email. Keep opens, but don't count them as a touch; automatic prefetching by mail clients makes them unreliable for attribution.

SendGrid → BigQuery · what breaks

Why this join usually fails — SendGrid → BigQuery

  1. 01

    Whatever join key you decide on never reaches SendGrid

    Marketing clicks land with tracking parameters; transactional clicks generally do not, and both arrive on the same domain.

  2. 02

    Receipt clicks credited to email marketing

    A customer clicking through their own order confirmation to check delivery is not an email marketing conversion. Untagged transactional traffic pooled with marketing makes the channel look far better than it is.

  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.

SendGrid → BigQuery · the fix

What working looks like — SendGrid → BigQuery

  • Whatever join key you decide on on every message

  • 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

SendGrid → BigQuery · architecture

How SendGrid and BigQuery actually connect

  1. 1

    SendGrid holds the truth

    A receipt and a promotional campaign are both an email in the same account. Only the campaign can plausibly have caused a purchase, and only if the purchase carries the campaign's identifier.

  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 SendGrid send.

  4. 4

    The event source decides reliability

    Send orders with the marketing campaign attributed where a tagged click preceded them.

  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.

SendGrid → BigQuery · normal or broken

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

Normal, not a fault

  • Whatever join key you decide on present on the message

  • Sent from your order system

  • 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

    Marketing clicks land with tracking parameters; transactional clicks generally do not, and both arrive on the same domain.

  • Sent from the browser

    A customer clicking through their own order confirmation to check delivery is not an email marketing conversion. Untagged transactional traffic pooled with marketing makes the channel look far better than it is.

  • 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

SendGrid → BigQuery · diagnose

Diagnostic order — SendGrid → BigQuery

  1. 01

    Count messages carrying whatever join key you decide on

  2. 02

    Follow one real conversion end to end

  3. 03

    Check whether transactional links carry campaign parameters

    If they do, every receipt click is being credited to email and the channel's reported performance is inflated.

  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.

SendGrid → BigQuery · prove

How it gets proven — SendGrid → BigQuery

Source of truth

Your order system, with marketing sends distinguished from transactional ones.

  • Whatever join key you decide on confirmed present on a live message.
  • Warehouse order counts and revenue reconciled against the source system for a fully closed window, with duplicates checked on the join key.
  • Orders from tagged marketing clicks reconciled against imported conversions, with transactional traffic excluded.

SendGrid → BigQuery · free audit

What we check in the free audit

  • Count messages carrying whatever join key you decide on
  • Follow one real conversion end to end
  • Check whether transactional links carry campaign parameters
  • Reconcile warehouse order counts against each platform for one closed window
  • Read the match rate, not the success message

Checked against

Your order system, with marketing sends distinguished from transactional ones.

Get my free conversion tracking audit

Free30 minutesNo obligation

SendGrid → BigQuery · when not to buy

When you don't need this — SendGrid → BigQuery

  • Measure identifier coverage yourself first — pull your last hundred messages and count how many carry whatever join key you decide on.
  • If you send only transactional mail, there is no marketing channel here to measure.
  • 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.

SendGrid → BigQuery · what we deliver

What gets built — SendGrid → BigQuery

  • Identifier capture into SendGrid

    Tag marketing links explicitly and attribute purchases from those; treat transactional traffic as returning customers, not as a channel.

  • Event source: your order system

    Send orders with the marketing campaign attributed where a tagged click preceded them.

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

Written guarantee

95%+ tracking accuracy

Measured against Your order system, with marketing sends distinguished from transactional ones.. Miss it and we keep working at no cost.

Get my free conversion tracking audit

From $400 · See packages

FAQ

SendGrid → BigQuery questions, answered

Use SendGrid's Event Webhook to post events to a small endpoint or cloud function that writes rows into BigQuery, deduplicating on sg_event_id.

Free · 30 min

Get SendGrid and BigQuery joined properly

Free30 minutesNo obligation