Agent context
Facebook Ads models
3 SQL models that turn the raw Facebook Ads tables into the reports people ask about. Deploy them in Weld and your agent queries the definitions behind every number.
How the set is built
- 5Raw tables
- 1Staging
- 3Core
- 2Analytics
Staging cleans each raw table once, core holds the logic, and analytics is the table dashboards and agents read.
- Ad ReportIntegrates with Facebook Ads and retrieves data from various tables such as ad_insight, account, campaign, ad_set, and ad. It selects specific columns from these tables and performs calculations to generate aggregated metrics such as spend, reach, impressions, clicks, CPC, CTR, and CPM. The template then joins these tables based on specific conditions and groups the results by certain columns.5 raw tables
- Conversion InsightsThis SQL template retrieves conversion insights data from Facebook Ads, including various metrics such as spend, reach, impressions, clicks, and more. It joins data from different tables like ad_insight, ad, and ad_roas_insight_conversion_insights to provide a comprehensive analysis of ad performance.3 raw tables
- Marketing Insights DashboardThis SQL template consolidates advertising data from multiple platforms, including Facebook, Google, LinkedIn, TikTok, Snapchat, and Pinterest, into a unified dataset. It aggregates metrics such as clicks, impressions, spend, and conversions, and calculates performance indicators like CTR, CPC, CPM, and conversion rate. The result is grouped by date, platform, account, campaign, and ad identifiers for comprehensive marketing insights.grain: day x platform x account x campaign x ad · 5 raw tables
- Weld or dbt
- The same SQL in both dialects. Sync the folder with GitHub Sync, or copy the dbt models into your project.
- Check before you rely on it
- Reconcile a month against Facebook Ads's own reports first. Each model's notes say what the synced data can and can't support.
Connect Facebook Ads.
Your agents start with context.
Sync Facebook Ads to your warehouse, deploy these models, and query them from Claude, Cursor or ChatGPT over MCP. Free for 14 days, no credit card.