Blog

Add a webhook destination for every server-side event

A single mirror webhook to your warehouse turns sGTM into a free real-time event stream.

Once sGTM forwards events to GA4, Meta, and others, adding one more webhook for your own warehouse is a small change with disproportionate value.

The pattern

A single Custom Tag in your sGTM container, triggered on all events, posts the payload to a webhook that lands the data in your warehouse.

const event = {
  event_name: getEventData('event_name'),
  timestamp: Math.floor(Date.now() / 1000),
  user_pseudo_id: getEventData('client_id'),
  page_location: getEventData('page_location'),
  event_params: getAllEventData()
};
sendHttpRequest('https://webhook.example.com/events', {
  method: 'POST',
  body: JSON.stringify(event),
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer ' + WEBHOOK_TOKEN
  }
});

The receiving endpoint

A small Cloud Function that receives the POST and writes to BigQuery via streaming insert. Mirror the GA4 BigQuery export schema. The parallel BigQuery pattern covers this.

What it gives you

  • Near-real-time event data in your warehouse.
  • Full event payload, not just what GA4 chose to expose.
  • Second source of truth for reconciling against GA4.
  • Visibility into events ad blockers prevented from reaching GA4.

Cost: BigQuery streaming insert is about $0.05 per million rows. For 5M events per month, infrastructure totals around $5-10.