To report spend from accounts in several currencies at each day's exchange rate, keep a table of daily rates in your warehouse and join it to your etlmcp rows on the date and the currency column. Every row etlmcp delivers has a currency column holding the ad account's currency, or for GA4 the property's currency. Reference rates such as the European Central Bank's are published on working days only, so carry the last published rate forward over weekends and holidays before you join. Otherwise an inner join drops every weekend and holiday of spend.
What etlmcp gives you to join on
The standard columns of every row include date, network, account_id, cost, conversion_value and currency. Ad platform rows are in the ad account's own currency: Meta and Google Ads rows take it from the account. A GA4 row takes it from the report, which states the property's currency, and a sync fails rather than store revenue with no currency. Without an fx rule, etlmcp converts nothing.
In the PostgreSQL table etlmcp writes, date is a date column, the metric columns such as cost and conversion_value are double precision, and currency is text. The SQL below is written for that table, which here is called marketing.ad_rows; use the schema and table you set on the PostgreSQL destination.
Where the rates come from
The ECB publishes euro foreign exchange reference rates on every working day, usually around 16:00 CET, and none on TARGET closing days. Each rate is quoted as units of the other currency per one euro: a USD rate of 1.09 means one euro buys 1.09 US dollars. The ECB says the rates are for information only and discourages using them for transactions, so they suit reporting, not accounting. The page lists 29 currencies, and the Russian rouble rate is suspended. If an ad account bills in a currency outside that list, you need another source for it.
The ECB offers the full history as a CSV or XML download. Its CSV uses a dot as the decimal separator. Reshape it into one row per date and currency before you load it:
CREATE TABLE marketing.fx_ecb (
rate_date date NOT NULL,
currency text NOT NULL, -- ISO code, as in etlmcp's currency column
per_eur double precision NOT NULL, -- units of this currency for one euro
PRIMARY KEY (rate_date, currency)
);
Fill the gaps with a date spine
The rates table has no rows for Saturdays, Sundays or TARGET holidays, and a long weekend leaves several days in a row with nothing. Ad platforms spend on all of those days. Build one row per calendar day and currency, each holding the last rate published on or before that day. PostgreSQL's generate_series produces the days, and a LATERAL subquery can read the day from the row before it and pick the latest earlier rate:
CREATE VIEW marketing.fx_daily AS
WITH days AS (
SELECT d::date AS day
FROM generate_series(
(SELECT min(rate_date) FROM marketing.fx_ecb)::timestamp,
current_date::timestamp,
interval '1 day') AS d
)
SELECT days.day AS rate_date, c.currency, r.per_eur, r.rate_date AS published_on
FROM days
CROSS JOIN (SELECT DISTINCT currency FROM marketing.fx_ecb) AS c
CROSS JOIN LATERAL (
SELECT f.per_eur, f.rate_date
FROM marketing.fx_ecb AS f
WHERE f.currency = c.currency
AND f.rate_date <= days.day
ORDER BY f.rate_date DESC
LIMIT 1
) AS r
UNION ALL
SELECT day, 'EUR', 1.0, day FROM days;
The last branch gives the euro itself a rate of 1 on every day, because the ECB does not list it. published_on tells you which day's rate a weekend row borrowed. If the view is slow, add an index on (currency, rate_date).
Convert by dividing
Because the rates are units per euro, divide an amount by the rate of its own day to get euros. Convert cost and conversion_value with the same day's rate, so that ROAS stays the same ratio it was in the account's currency:
CREATE VIEW marketing.ad_rows_eur AS
SELECT a.date, a.network, a.account_id, a.campaign_id, a.campaign_name,
a.currency AS account_currency,
a.cost / fx.per_eur AS cost_eur,
a.conversion_value / fx.per_eur AS conversion_value_eur,
fx.published_on
FROM marketing.ad_rows AS a
LEFT JOIN marketing.fx_daily AS fx
ON fx.rate_date = a.date
AND fx.currency = a.currency;
For a report in another currency, such as US dollars, convert to euros first and then multiply by that day's USD rate from a second join to fx_daily. Do not convert cpc, cpm or cpa row by row and then average them. Add up the converted cost and the clicks, impressions or conversions, and divide afterwards, as ratios from sums explains.
Use a LEFT JOIN, as above, and check for rows that found no rate. They show up as a null cost_eur next to a cost that is not null: a currency the ECB does not publish, a date before your first loaded rate, or a row with an empty currency.
SELECT a.currency, min(a.date), max(a.date), count(*)
FROM marketing.ad_rows AS a
LEFT JOIN marketing.fx_daily AS fx
ON fx.rate_date = a.date AND fx.currency = a.currency
WHERE fx.per_eur IS NULL AND a.cost IS NOT NULL
GROUP BY a.currency;
Keep the conversion in views rather than in a copy of the data. When a later sync rewrites recent days, as the trailing window does, the views convert the new figures at query time with nothing to refresh.
Rows an fx rule already converted
A pipeline can also convert in flight with an fx rule. That rule multiplies an amount by one fixed rate per currency, the same on every date, and then writes the target currency into the row's currency column. Nothing in the delivered row records the currency it came in. So pick one place to convert:
- If the pipeline has an
fxrule, its rows are already in the target currency, at the rule's fixed rate. Do not join them to the daily rates as though they were original amounts: the join reads the target fromcurrency, so the result stacks a daily rate on top of the fixed one, and the original currency cannot be recovered from the row. - An
fxrule converts one column. A rule oncostalone also convertscpc,cpmandcpa, but leavesconversion_valuein the account's currency whilecurrencyalready names the target. Check the pipeline's rules before you trustcurrencyfor revenue. - To switch from fixed rates to daily ones, remove the
fxrule and sync the history again with a backfill, so that the table holds the original amounts and their real currency.
For how each platform, GA4 and Shopify decide what currency they report in, see currency handling.