To get every ad platform into one PostgreSQL table, give each pipeline a PostgreSQL destination with the same schema and table name. Several pipelines can write to that one table: on each run, a pipeline deletes only the rows that carry its own ID in the _etlmcp_pipeline_id column and fall in the run's dates, then inserts its fresh rows. Every row has the same canonical columns whatever the network: the date, the network, the account, campaign, ad group and ad, the common metrics and the currency. Most platforms' dates are the ad account's own local day, so a day in one network's rows is not always the same 24 hours as in another's.
Set it up
- Create one PostgreSQL destination, or several that point at the same host, database, schema and table. See PostgreSQL destination setup for the fields.
- Point each pipeline (Google Ads, Meta, TikTok and so on, one per source) at that table.
- Run them. The first run that finds no table creates it, with one column per field plus
_etlmcp_pipeline_id. Later pipelines add the extra columns their platform brings when they first appear.
The table must be one etlmcp created. A table without the _etlmcp_pipeline_id column is refused, so you cannot point pipelines at a table you made by hand. The details of the delete and insert, and the errors a shared table can raise, are on how PostgreSQL rows are replaced.
A backfill of one network never removes another network's days. A run that returns no rows still clears that pipeline's rows for its dates, so a paused campaign leaves no stale figures.
The columns every row has
The canonical columns come first, in this order:
| Column | Type in PostgreSQL | What it holds |
|---|---|---|
date |
date | The day the figures belong to |
network |
text | google, meta, microsoft, tiktok, linkedin, pinterest, snapchat, ga4, shopify or mock |
account_id, account_name |
text | The ad account, GA4 property or Shopify store |
campaign_id, campaign_name |
text | The campaign |
adgroup_id, adgroup_name |
text | The ad group (Meta's ad set) |
ad_id, ad_name |
text | The ad |
impressions, clicks, cost, conversions, conversion_value |
double precision | The common metrics |
ctr, cpc, cpm, cpa |
double precision | Ratios worked out for that one row |
currency |
text | The account's currency code |
After these come the platform's extra columns, named extra.<key>, and the _etlmcp_pipeline_id column. A missing ID is stored as an empty string, not as NULL, so filter with campaign_id <> '' rather than IS NOT NULL.
cost and conversion_value stay in each account's own currency: etlmcp never converts them unless the pipeline has an fx rule. If your accounts bill in different currencies, group or filter by currency before you add cost up.
Whose day a date is
A row's date is the calendar day the platform reported it on. For most networks that is the account's own time zone:
- Google Ads: the account's time zone. Google's help center says Google Ads statistics show local time in the time zone picked for the account.
- Meta, TikTok and Snapchat: the ad account's time zone.
- GA4: the property's time zone.
- Shopify: the day an order was placed, in the store's time zone.
- LinkedIn and Pinterest: UTC days.
- Microsoft Advertising: etlmcp sends the London (Greenwich Mean Time) zone setting with every report request, in place of the Pacific time default.
A New York Google Ads account and a Pinterest account do not cut their days at the same moment, so single-day comparisons across networks differ at the edges; weekly and monthly totals differ less.
Queries that work on the shared table
Spend and clicks by day and network, with ratios worked out from the sums rather than averaged:
SELECT date, network, currency,
SUM(cost) AS cost,
SUM(impressions) AS impressions,
SUM(clicks) AS clicks,
SUM(cost) / NULLIF(SUM(clicks), 0) AS cpc,
SUM(clicks) / NULLIF(SUM(impressions), 0) AS ctr,
SUM(cost) / NULLIF(SUM(conversions), 0) AS cpa
FROM public.ad_performance
WHERE network NOT IN ('ga4', 'shopify')
AND date >= CURRENT_DATE - 28
GROUP BY date, network, currency
ORDER BY date, network;
Never average the stored ctr, cpc, cpm or cpa columns: each is the ratio for its own row, and an average of ratios weights a small ad the same as a large one.
GA4 and Shopify rows sit in the same table but measure different things. GA4 leaves the ad metrics empty and puts its own figures in extra columns such as extra.sessions, extra.key_events and extra.revenue. Shopify rows carry extra.orders and extra.revenue per store and day, with empty campaign IDs. Keep them out of ad totals, as the NOT IN filter above does, or you count conversions twice.
Extra column names contain a dot, so PostgreSQL needs them in double quotes. PostgreSQL's documentation explains that a quoted identifier may hold any character other than code zero and keeps its case, while an unquoted one is folded to lower case:
SELECT a.date, a.currency, a.cost, s.revenue,
s.revenue / NULLIF(a.cost, 0) AS revenue_per_cost
FROM (
SELECT date, currency, SUM(cost) AS cost
FROM public.ad_performance
WHERE network NOT IN ('ga4', 'shopify')
GROUP BY date, currency
) a
JOIN (
SELECT date, currency, SUM("extra.revenue") AS revenue
FROM public.ad_performance
WHERE network = 'shopify'
GROUP BY date, currency
) s USING (date, currency)
ORDER BY a.date;
To see which pipeline wrote what, group by the marker column:
SELECT _etlmcp_pipeline_id, network, MIN(date), MAX(date), COUNT(*)
FROM public.ad_performance
GROUP BY _etlmcp_pipeline_id, network;
Before you build reports
- One network can appear under several pipeline IDs if you sync several accounts. That is expected: each account's pipeline replaces only its own rows.
- Replace
public.ad_performancewith your schema and table name. - To chart the table, see Metabase on PostgreSQL for one way to connect a BI tool, and full history vs range replace for why a restated day is corrected on the next run.