Robyn, Meta's open-source marketing mix modelling package, wants weekly data as its default grain, at least two years of it, and enough rows that each independent variable has about ten observations behind it. Its analyst guide also asks you to split digital media at least by channel or publisher, to use what actually ran rather than what was planned, and to collect spend next to an exposure metric such as impressions.
The checklist
| Requirement | What Robyn's guide recommends |
|---|---|
| Time grain | Weekly is best practice. Daily is acceptable, but it brings more noise and needs extra validation. |
| History | Two years of weekly data at the least. With only monthly data, four to five years. |
| Model size | About one independent variable for every ten observations; rows roughly seven to ten times the number of columns. |
| Digital breakout | At least by channel or publisher, such as social, search and display. Finer splits only to answer a specific question. |
| Actual or planned | Actual delivery first. Planned figures only where actuals are not tracked, such as for out-of-home. |
| Media metric | An exposure metric as the model input (impressions for digital, GRPs or TARPs for TV and radio), with spend collected too. |
| Variation | Each variable must move over time. A channel held at the same level for the whole period gives the model nothing to estimate from. |
Granularity and the week start
Daily data has more variation but more noise, and the guide asks for extra checks before you trust it. There is one case where the guide points the other way: a short model window. Half a year of weekly rows is too thin to fit, so for a window that short it suggests daily data instead.
If you model weekly, agree on the first day of the week before anyone pulls data. The guide names Sunday and Monday as the usual choices. Every source, from the ad platforms to your sales system, has to roll up to the same week, or spend and sales land in different rows.
How many variables your rows can carry
The guide's sizing rule ties the number of variables to the number of rows. Two years of weekly data is 104 rows. At seven rows per column that is about 15 columns; at ten rows per column it is about 10. Those columns have to cover paid media, organic activity, promotions, seasonality and any macroeconomic or competitor variables together. If you want each publisher, and within it each format, as its own variable, you need either more weeks or a daily grain with its extra validation.
This is why the breakout rule has a floor and not a ceiling. Splitting digital by channel or publisher is the minimum. Splitting Facebook static ads from video, for example, is worth it only when that question matters to the business and the rows can carry the extra variable.
Spend and exposure
Robyn treats exposure as the better model input, because a dollar buys a different reach on each channel. For digital media that means impressions; the guide advises against clicks, which miss people who saw an ad and converted without clicking. You still need spend: return on investment is calculated from it, and the budget allocator, which simulates different splits of budget between channels, needs it too. Collect both for every paid channel.
The dependent variable
The KPI is the business outcome the company reports on, most often sales by value or volume, but account sign-ups or home loan applications in some sectors. It does not come from the ad platforms. The conversions each platform attributes to its own ads are that platform's claim, so keep them for reporting, not as Robyn's dependent variable.
Building the media columns from etlmcp
Every etlmcp ad connector maps its figures onto the same columns: date, network, account, campaign, ad group and ad ids and names, then impressions, clicks, cost, conversions and conversion_value, plus currency. The Meta connector requests ad-level rows one day at a time, so a channel or publisher breakout, or a campaign-level one, is a GROUP BY away. cost and conversion_value are in each ad account's own currency and are never converted, so filter on currency or convert before you add accounts together.
Robyn wants one row per week and one column per variable. In a PostgreSQL destination, you can build that wide shape in SQL. PostgreSQL's date_trunc('week', …) follows ISO weeks, which start on Monday. The query below shifts the date by a day first so that weeks start on Sunday; drop the shift if your team agreed on Monday. marketing.ad_facts stands for the schema and table you set on the destination.
SELECT (date_trunc('week', date + 1) - interval '1 day')::date AS week_start,
coalesce(sum(cost) FILTER (WHERE network = 'meta'), 0) AS meta_spend,
coalesce(sum(impressions) FILTER (WHERE network = 'meta'), 0) AS meta_impressions,
coalesce(sum(cost) FILTER (WHERE network = 'google'), 0) AS google_spend,
coalesce(sum(impressions) FILTER (WHERE network = 'google'), 0) AS google_impressions
FROM marketing.ad_facts
WHERE currency = 'USD'
GROUP BY 1
ORDER BY 1;
The impressions columns go to Robyn's paid_media_vars and the spend columns stay beside them for ROI. A week in which nothing ran at all has no rows, so join the result to a calendar of weeks if a channel went dark for a while.
History you can reach
How far back you can pull depends on your plan: Free keeps 30 days, Starter 365, Team 365, Agency 730 and Scale 3650. Only Agency and Scale keep enough for Robyn's two-year minimum, and a run started by hand covers at most 366 days, so a two-year backfill takes more than one run. The history window page explains the rule, a backfill pulls older days, and how much history an MMM needs covers why to start storing daily rows in your own database now.
Review the data before modelling
The guide ends data collection with a review: look for missing weeks and short years, check how strongly the independent variables correlate with each other and with the KPI, and compare spend over time with the media plans and with the people who ran the campaigns. Variables that barely move, or that are too small to plausibly shift the KPI, are candidates to leave out; test the model with and without them.