Facebook Ads model

Conversions by action type daily

Every conversion event Meta reports, per ad and day: purchases, leads, add to carts, registrations, app installs, custom conversions. Ads Manager's "Results" columns, one row per event.

Grain
date_day x account_id x ad_id x action_type
Built from
  1. 8
    Raw tables
  2. 8
    Staging
  3. 2
    Core
  4. 1
    Analytics
Reads from Facebook Ads
accountadad_roas_insightad_roas_insight_action_valuesad_roas_insight_actionsad_setad_set_attributioncampaign
Ships as
Weld and dbt SQL, open source on GitHub
core.facebook_ads.conversions_by_action_type_daily
1-- core.facebook_ads.conversions_by_action_type_daily
2-- Every conversion event Meta reports, per ad and day: purchases, leads, add to
3-- carts, registrations, app installs, custom conversions. Ads Manager's
4-- "Results" columns, one row per event.
5--
6-- Grain: date_day x account_id x ad_id x action_type. Currency: the ad account's.
7-- Depends on: staging.facebook_ads.ad_roas_insight_actions,
8-- .ad_roas_insight_action_values, core.facebook_ads.ad_performance_daily
9--
10-- action_count comes from the actions array, action_value from the
11-- action_values array (NULL for events Meta reports no value for).
12--
13-- Do not sum action_count across action types: Meta reports the same purchase
14-- under several types (purchase, omni_purchase, offsite_conversion.fb_pixel_purchase,
15-- onsite_web_purchase ...). Pick one type per event. spend is not repeated here;
16-- join to ad_performance_daily on date_day, account_id and ad_id for cost per
17-- action, after filtering to one action type.
18
19WITH counts AS (
20    SELECT
21        date_day, account_id, ad_id, action_type,
22        SUM(action_count)          AS action_count
23    FROM {{staging.facebook_ads.ad_roas_insight_actions}}
24    GROUP BY 1, 2, 3, 4
25),
26
27action_values AS (
28    SELECT
29        date_day, account_id, ad_id, action_type,
30        SUM(action_value)          AS action_value
31    FROM {{staging.facebook_ads.ad_roas_insight_action_values}}
32    GROUP BY 1, 2, 3, 4
33),
34
35ads AS (
36    -- One row per ad and day already; only the labels are needed.
37    SELECT date_day, account_id, ad_id, account_name, currency,
38           campaign_id, campaign_name, ad_set_id, ad_set_name, ad_name
39    FROM {{core.facebook_ads.ad_performance_daily}}
40)

This model and the 10 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().

Notes

How it counts. And where it stops.

action_count comes from the actions array, action_value from the action_values array (NULL for events Meta reports no value for). Do not sum action_count across action types: Meta reports the same purchase under several types (purchase, omni_purchase, offsite_conversion.fb_pixel_purchase, onsite_web_purchase ...). Pick one type per event. spend is not repeated here; join to ad_performance_daily on date_day, account_id and ad_id for cost per action, after filtering to one action type.

Raw tables it reads

  • raw.facebook_ads.account
  • raw.facebook_ads.ad
  • raw.facebook_ads.ad_roas_insight
  • raw.facebook_ads.ad_roas_insight_action_values
  • raw.facebook_ads.ad_roas_insight_actions
  • raw.facebook_ads.ad_set
  • raw.facebook_ads.ad_set_attribution
  • raw.facebook_ads.campaign

Put Facebook Ads in front
of your agents.

Connect Facebook Ads, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.