To put ad spend and GA4 sessions or revenue in one Tableau view, relate the two tables in the logical layer instead of joining them, and relate them on date plus a campaign key. A relationship lets each table be summed at its own level of detail before the two are combined, so a campaign's cost is counted once however many GA4 rows sit under it. A join merges the rows first: every ad row is repeated for each matching GA4 row, and SUM(cost) grows with the number of matches.
Why a join double-counts
The two kinds of rows etlmcp writes are not at the same grain. An ad platform row describes one day of one campaign, ad group or ad, with cost, clicks and impressions. A GA4 row describes one day of one campaign and one source / medium: etlmcp asks GA4 for date, session campaign ID, session campaign name and session source / medium, and keeps one row for each combination.
Say a Google Ads campaign spent 500 on a day, and GA4 split that campaign's sessions that day across google / cpc and google / organic. A physical join on date and campaign gives two rows, each carrying the 500, and the view shows 1,000 of spend. If the ad table holds ad-level rows, every ad row is repeated for each source / medium, and the error multiplies.
A join can also lose measure values that have no match. Relationships keep the tables apart and let Tableau choose the joins for each sheet, based on the fields the sheet uses.
The settings to use
Tableau's performance options decide whether a relationship protects you:
- Cardinality: Many on both sides. With Many, Tableau aggregates each table before joining, and aggregate values are not duplicated. Neither of your tables has one row per date and campaign, so do not set One: with keys that are not unique, One can show inflated totals.
- Referential integrity: Some Records Match. This keeps measure values that have no match on the other side, such as spend on a day GA4 recorded no sessions for that campaign, or GA4 sessions from campaigns that never spent. All Records Match uses inner joins and can drop those values from the view.
Both are Tableau's defaults when it detects no key constraints, and etlmcp's tables declare none, so check the settings rather than change them. The fields on each side of a relationship must have the same data type in the database; changing the type on Tableau's Data Source page does not change what Tableau queries.
Relate on date and campaign, not ad group
Add two field pairs in the relationship: date to date, and campaign_id to campaign_id. Tableau calls a relationship with more than one pair a compound relationship.
Do not add adgroup_id or adgroup_name. In etlmcp's GA4 rows those two columns hold the session source / medium, such as google / cpc, because GA4 has no ad groups. On an ad row they hold the platform's ad group, so the values never match, and with Some Records Match every row shows up unmatched. GA4 rows also leave ad_id empty.
On ad rows, campaign_id is the platform's campaign ID. On GA4 rows it is the campaign ID GA4 recorded for the session, and when GA4 has none (an empty value or (not set)) etlmcp stores the campaign name in campaign_id instead. If your links carry campaign names rather than IDs, relate on campaign_name instead, or use a calculated field on one side: Tableau relationships accept calculated fields.
Getting two tables out of one PostgreSQL table
Several pipelines can write to one PostgreSQL destination table: etlmcp marks each row with the _etlmcp_pipeline_id column and replaces only its own pipeline's rows. Every row also has a network column, ga4 for GA4 rows and the connector key, such as google or meta, for ad rows.
Tableau needs two logical tables to relate, so create two views in PostgreSQL and drag each view onto the canvas. GA4's metrics are not canonical columns: they arrive as extra columns whose names keep the extra. prefix and its dot, so quote them in double quotes. Replace public.marketing_rows with your schema and table.
CREATE VIEW public.ga4_campaign_days AS
SELECT date, campaign_id, campaign_name,
adgroup_name AS source_medium,
"extra.sessions" AS sessions,
"extra.key_events" AS key_events,
"extra.orders" AS orders,
"extra.revenue" AS revenue,
currency
FROM public.marketing_rows
WHERE network = 'ga4';
CREATE VIEW public.ad_rows AS
SELECT date, network, account_id, campaign_id, campaign_name,
impressions, clicks, cost, conversions, conversion_value, currency
FROM public.marketing_rows
WHERE network IN ('google', 'meta');
An extra column exists only once a row that carries it has been loaded, so create the GA4 view after the first GA4 sync.
Measures that still mislead
A relationship stops the duplication, but some measures cannot be added up at all:
- Users. GA4's
total_usersandnew_userscount distinct users per day, campaign and source / medium. Summed across days or source / mediums, a person is counted more than once. Use sessions for totals. - Rates.
ctr,cpc,cpmandcpaare worked out on each ad row. Summing or averaging them across rows gives a wrong figure: build calculated fields such asSUM([cost]) / SUM([clicks])instead. - Currency. Cost is in the ad account's currency and revenue in the GA4 property's. Put
currencyin the view, or filter to one, before you divide revenue by spend.
For how GA4 counts sessions and users, see users and sessions in GA4. The GA4 fields etlmcp pulls are listed on the GA4 connector page.