Query Facebook Ads data in AWS Athena
Load Facebook and Instagram ad performance into Athena tables in your own AWS account with OWOX Data Marts: ads, creatives and insights, each in its own table, refreshed on a schedule. Query it next to web analytics and CRM to see which ads bring customers and deals.
AWS AthenaDateCostClicksDaily 09:00Facebook Ads counts results by its own attribution, and the spend never sits next to your CRM in AWS Athena.
Paste this into your AI assistant. It creates a Facebook Ads Data Mart on your AWS Athena storage, loads ads, creatives and insights into separate tables on a schedule, and joins spend to your deals.
The prompt
Read https://www.owox.com/ai-agent-setup.md and follow it to set up OWOX Data Marts for me, starting from /connectors/free-facebook-ads-connector-to-aws-athena.md. The task: load Facebook Ads ad insights and creatives into AWS Athena on a daily schedule and write a query that shows spend per ad next to the CRM deals its visitors opened. Tag the links you give me with utm_campaign=ai-task and utm_term=data-foundation. Use what you know about my context and goals
Facebook Ads Endpoints
15 Facebook Ads endpoints you can import. Each lands in its own table in your data warehouse.
Ad
Individual ads with their creative, status, and links to their campaign and ad set.
32 fieldsAd Account
Your ad account settings, status, currency, and billing details.
61 fieldsAd Account User
Users with access to an ad account and their assigned roles.
2 fieldsAd Creatives
The images, videos, text, and other visual elements used in your ads.
65 fieldsAd Insights
Daily performance metrics for each ad — impressions, clicks, spend, and conversions.
100 fieldsTime seriesAd Insights by Ad Set
Daily ad set performance with reach deduplicated to match Meta Ads Manager.
92 fieldsTime seriesAd Insights by Age and Gender
Daily ad performance broken down by audience age range and gender.
102 fieldsTime seriesAd Insights by Campaign
Daily campaign performance with reach deduplicated to match Meta Ads Manager.
89 fieldsTime seriesAd Insights by Country
Daily ad performance broken down by the country where your audience is located.
101 fieldsTime seriesAd Insights by Device Platform
Daily ad performance broken down by the device type your audience used.
101 fieldsTime seriesAd Insights by Link URL Asset
Daily ad performance broken down by the link URL shown in your ads.
101 fieldsTime seriesAd Insights by Product ID
Daily ad performance broken down by individual product from your catalog.
101 fieldsTime seriesAd Insights by Publisher Platform and Position
Daily ad performance broken down by where your ads appeared — platform and placement position.
102 fieldsTime seriesAd Insights by Region
Daily ad performance broken down by the region where your audience is located.
101 fieldsTime seriesAds
Individual ads with their status, creative, and campaign hierarchy.
24 fields
Why query Facebook Ads with your web analytics and CRM in Athena
Ads Manager reports what Facebook and Instagram say they delivered, counted by Meta's own attribution. To see which ads brought customers and revenue, spend has to sit next to website touch points and CRM deals in one warehouse that you query with Athena SQL.
- Put Facebook next to Google, TikTok and Microsoft spend in one table
- Connect ad clicks and sign-ups to the orders and deals they became
- Query spend, reach and ROAS with the Athena SQL you already use
Your data warehouseAdTouch pointDealJoined by idAd seen or clickedDeal months laterOne Athena query links the ad to the deal.Step 1: Connect Facebook Ads and pick the fields
Create a Data Mart on your Athena storage and choose Facebook Ads as the source. Sign in with Facebook or add an access token, list your ad account ids and tick only the fields you need.
- 15 endpoints and 1172 fields to choose from
- Ad Insights alone has 100 fields: spend, reach, clicks, conversions, ROAS
- One Data Mart per endpoint, so each breakdown stays its own table
Step 2: Load Facebook Ads into an Athena database and table
Choose the Athena database and table, or keep the pre-filled ones. Run it and the first load, from the start of the previous month through today, lands in your own AWS account.
- Insights go to a table such as facebook_ads_ad_account_insights
- Query results go to the S3 output bucket you set up for Athena
DestinationDatabasefacebook_adsTablead_account_insightsRun
Tablefacebook_ads.ad_account_insig…Step 3: Know every column before you write the query
Once the first run finishes, the output schema lists every field with a plain-words description, not an API identifier. Your quality checks can read it too.
- Results such as actions and action_values are fields of their own, with descriptions
- Anyone on the team can read the table
facebook_ads.ad_account_insightsOutput schemaFieldDescriptiondate_startThe start date for your data…spendThe estimated total amount of…impressionsThe number of times your ads…clicksThe number of clicks on your ads.reachThe number of people who saw…purchase_roasThe total return on ad spend…Step 4: Connect the Facebook Ads tables in Athena
Ad accounts, ads, creatives and insights are separate Athena tables, joined by ids. Join them and they form one Facebook Ads model.
- ad_id in Ad Insights is the id of the ad, and creative_id on the ad points to its creative
- Campaign and ad set ids ride on every row, so spend rolls up to either level
Step 5: Schedule the Athena load and backfill history
Set it up once. A daily scheduled refresh keeps the Athena tables current, and a manual backfill brings in any period you missed.
- Run it daily, weekly, monthly or on an interval
- Backfills longer than a month are split into segments of up to 31 days for you
Step 6: Use the same Athena tables in every tool
The same tables feed your model, , , assistants like Claude and ChatGPT, and scheduled AI insights in Slack or email.
- Blend Facebook with Google and TikTok spend once
- All reports read the same Athena tables
- 0.41.0Rotating a warehouse key is one change: Storages share reusable Credentials
- 0.41.0Shared SQL logic stays in one place: build a Data Mart on top of another
- 0.41.0Rotating a connector key is one change: Sources share reusable Credentials
- 0.39.0Reload a year of history in one backfill, not twelve
- 0.39.0Long Facebook Ads imports no longer fail on a corrupted response
Why OWOX for Facebook Ads in AWS Athena
Hand-built Marketing API scripts, a generic ETL tool or manual exports each get Facebook data out. OWOX also lands it in your AWS account, readable and ready to model.
- You own the data. It lands in your own AWS account, in tables you control, not inside an ad account.
- One table per breakdown. Country, region, age and gender, device, placement and product breakdowns each load into their own table, so you take the cuts you need and leave the rest.
- Ready for a data model. Separate Athena tables joined by ad, ad set and campaign ids, built to connect to web analytics and CRM.
- Maintained for you. No API scripts for you to patch when Meta updates the Marketing API.
- Free to self-host. The open-source OWOX Data Marts runs in your own infrastructure, with Athena as its data storage.
You are booked. The invitation is on its way to , with the calendar invite and the meeting link.