LW IT Solutions logo LW IT Solutions logo LW IT Solutions
« Blog Overview /Digital Analytics / How to Allocate Marketing Budgets Using GA4
Read this article in other languages:

How to Allocate Marketing Budgets Using GA4

How to Allocate Marketing Budgets Using GA4How to Allocate Marketing Budgets Using GA4

Management Summary

Marketing budgets determine which advertising channels receive money. GA4, Google's website analysis service, helps compare how recorded contacts with ads contribute to purchases. This matters when a sale follows several steps, such as a search ad and a newsletter, rather than one click. Combining those insights with costs and profit margins gives a better basis for allocating spending. The reported shares describe observed journeys; only controlled budget changes can show whether extra spending brings extra sales.

Contents
  1. What GA4 attribution shows
  2. From a report to a budget decision
  3. What BigQuery can contribute
  4. Consent and measurement gaps
  5. Questions and answers
  6. Sources

Marketing budgets need more than a list of last clicks. A purchase can follow a search, an advertisement and an email. Attribution assigns credit to those contacts; the result supports a budget hypothesis, but does not guarantee the best allocation.

What GA4 attribution shows

In GA4, an important action such as a purchase can be marked as a key event. A path is the recorded sequence of contacts before an action, such as search, advertisement and purchase. Data-driven attribution (DDA) estimates credit from those available records. Last-click attribution assigns credit according to a fixed rule. A change between models shows how strongly the chosen allocation rule affects the result. It does not prove that a channel caused additional sales.

The Advertising area contains attribution-model and key-event-path reports. The path report distinguishes early, middle and late contacts. Only recorded or modeled information can appear; a displayed path is not a complete history of every real-world interaction. First-click and linear models are no longer selectable GA4 attribution models.

GA4 data-driven attribution and BigQuery event analysis shown as separate outputs
Attribution assigns credit to contacts. The BigQuery event export supports a separate path analysis; GA4 DDA shares are not exported as illustrated fractions.

From a report to a budget decision

  1. Outcome definition: qualified leads (enquiries that meet defined business criteria), net revenue or contribution margin (revenue minus variable costs), with a consistent period and currency.
  2. Measurement checks: duplicate purchases, missing transaction IDs, campaign parameters, consent settings and late events.
  3. Model comparison: identification of channels whose assigned credit changes. A higher DDA share alone does not identify where in the journey that contribution occurred; the path report adds context.
  4. Bounded test: specification of the budget change, evaluation period, success metric and stopping rule. A budget reduction can reduce sales even when last-click credit appears high.

ROAS means attributed revenue divided by advertising spend. For example, 4,000 in revenue and 1,000 in spend gives ROAS 4. This is not profit: costs, returns and the attribution model still matter. Automated budget changes need spend limits, monitoring and a way to reverse a change.

What BigQuery can contribute

The daily export provides event data without report sampling. Export configuration and limits still affect coverage. GA4 modeled key events and the proprietary DDA credit allocation are not reproduced by the event export. Custom SQL or Python models therefore answer a separately defined question.

Google documents session traffic attribution in session_traffic_source_last_click. Missing source fields must not automatically become direct traffic. A dashboard can combine a clearly defined export-based calculation with advertising costs, provided the calculation uses matching records, currencies and dates—for example, session figures compared with session figures rather than user counts.

Earlier BigQuery result table with paths grouped by user_pseudo_id

Example: observed session starts before each purchase

This teaching query reads one day and keeps purchases separate by transaction ID. The required project and dataset names are placeholders. Purchases without a usable transaction ID or pseudonymous identifier are excluded and need a separate completeness check. Repeated purchase records for the same transaction are reduced to the earliest timestamp.

WITH purchases AS (
  SELECT user_pseudo_id, stream_id,
    ecommerce.transaction_id AS transaction_id,
    MIN(event_timestamp) AS purchase_time
  FROM `your_project.analytics_123456789.events_20260701`
  WHERE event_name = 'purchase'
    AND user_pseudo_id IS NOT NULL
    AND NULLIF(ecommerce.transaction_id, '') IS NOT NULL
  GROUP BY user_pseudo_id, stream_id, transaction_id
), session_starts AS (
  SELECT DISTINCT user_pseudo_id, stream_id, event_timestamp,
    (SELECT value.int_value FROM UNNEST(event_params)
     WHERE key = 'ga_session_id') AS session_id,
    CONCAT(
      COALESCE(session_traffic_source_last_click.cross_channel_campaign.source, '(unknown)'),
      ' / ',
      COALESCE(session_traffic_source_last_click.cross_channel_campaign.medium, '(unknown)')
    ) AS source_medium
  FROM `your_project.analytics_123456789.events_20260701`
  WHERE event_name = 'session_start'
)
SELECT p.user_pseudo_id, p.stream_id, p.transaction_id,
  p.purchase_time,
  STRING_AGG(s.source_medium, ' > '
    ORDER BY s.event_timestamp, s.session_id) AS observed_path
FROM purchases p
LEFT JOIN session_starts s
  ON s.user_pseudo_id = p.user_pseudo_id
  AND s.stream_id = p.stream_id
  AND s.event_timestamp <= p.purchase_time
GROUP BY p.user_pseudo_id, p.stream_id, p.transaction_id, p.purchase_time;

The output contains observed session starts, not GA4 DDA shares. An absent path stays NULL. A single day truncates earlier contacts; a longer analysis needs a bounded events_* date range and an explicit lookback window: the maximum period before each purchase during which contacts are included. Missing session-start events and missing session attribution remain limitations. The screenshot illustrates an older per-user output and does not show the revised per-transaction result.

Consent and measurement gaps

Consent Mode changes tag behavior according to consent settings. In advanced mode, denied storage can still produce measurements without cookies. Availability of modeling depends on the setup and data; neither statistical completeness nor legal compliance follows merely from enabling the feature. Enhanced conversions are a separate configuration and not a prerequisite for the SQL example.

Questions and answers

Must BigQuery totals be lower than the GA4 interface?

No. Modeling, reporting identity (the method used to recognize the same user across visits), filters, late data and query logic can all affect comparisons. The metric, time zone, period and scope need to match first. A discrepancy can also reveal a query defect.

Can interface totals be multiplied by channel ratios from the export?

Only as an explicitly labeled estimate with justified assumptions. The two calculations may include different purchases or users and assign credit differently. Combining their numbers does not automatically produce valid channel revenue.

What helps when data volume is small?

A longer, business-relevant observation period and fewer decision segments can improve stability. Path order remains descriptive and does not establish the return from an additional unit of advertising spend. Small controlled tests and business economics complement attribution.

Lukas Wojcik

Lukas Wojcik

Systems architect and technology enthusiast specializing in scalable tracking solutions, GMP Stack (GA4 & GTM), and robust backend architectures. Advocate for clean code and privacy-first design.

Get in touch

A question or an idea for a web project? Tell me a little about it. This form uses reCAPTCHA and formconfirmed to protect against spam.

Write a comment

Differing figures from other accounts and questions about the setup are welcome here.

The email address is not published. Required fields are marked with an asterisk.

LUKASWOJCIK.COM · NEWSLETTER

Fresh ideas in your inbox

New articles, practical tools and updates from the projects.

Choose topics (optional)
No selection: all topics.

Subscription starts after confirmation by email. · Privacy

Privacy · Newsletter

Email address, language, selected topics and subscription/confirmation dates are stored to deliver the newsletter. Double opt-in is required. Every issue includes an immediate unsubscribe link. Formconfirmed checks the signup for spam. No email open or click tracking.

Read the full privacy policy ↗