Facebook Ads

AgenticBI connects directly to the Meta (Facebook) Marketing API to pull ad account data, ad performance metrics, and campaign insights into a single analytics platform.

Analyze your Facebook Ads spend, impressions, clicks, conversions, and ROI alongside data from your other sources - no manual CSV exports or spreadsheet wrangling needed.

Overview

AgenticBI integrates with the Meta Graph API v24.0 (Marketing API) via OAuth. Once connected, you can pull ad accounts, individual ad details, and performance insights with full pagination support.

Connecting

  1. Log in to AgenticBI and select "Queries" from the left sidebar.

  2. Click on the "New Datasource +" button and select Facebook from the list of datasources.

  3. Click "Connect to Facebook" to authorize AgenticBI to access your ad account data. You will be redirected to Facebook to approve the connection.

  4. After approving, you'll be redirected back to AgenticBI. Click "Save" to finish setting up the datasource.

Note: Facebook access tokens are long-lived and do not require periodic refresh. However, if you change your Facebook password or revoke app permissions, you will need to reconnect.

Collections

After connecting, select a collection from the dropdown to query your Facebook Ads data.

Ad Account Listing

Retrieves all ad accounts associated with your Facebook user. Use this to find your Account IDs for use with other collections.

Default Cloud9QL:

select data;
select expand(data);

The response includes account IDs and names. Use the account ID (without the act_ prefix) in the Facebook Ads collection.

Facebook Ads

Retrieves ads for a specific ad account, including status, campaign association, and configuration details.

Required Parameters:

  • Facebook Account Id - Your Facebook Ad Account ID (numeric, without the act_ prefix).

Fields returned: account_id, bid_amount, campaign_id, configured_status, name, recommendations, status, adlabels, created_time, conversion_domain, updated_time, adset_id

Default Cloud9QL:

select data;
select expand(data);

Facebook Ads Insight

Retrieves performance metrics for a specific ad, ad set, campaign, or account. This is the most powerful collection for analyzing ad performance.

Required Parameters:

  • Facebook Ads Id - The ID of the ad, ad set, campaign, or account to get insights for.
  • Date - Date preset for the reporting period. Options: today, yesterday, this_month, last_month, this_quarter, maximum, last_3d, last_7d, last_14d, last_28d, last_30d, last_90d, last_week_mon_sun, last_week_sun_sat, last_quarter, last_year, this_week_mon_today, this_week_sun_today, this_year.

Optional Parameters:

  • Action Attribution Window - Attribution model for conversions. Options: 1d_view, 7d_view, 28d_view, 1d_click, 7d_click, 28d_click, dda, default. Default is ["7d_click","1d_view"].
  • Time Increment - Granularity of results. Use all_days for a single aggregated result, monthly for monthly breakdown, or a number 1-90 for N-day periods.
  • Fields - Comma-separated list of metrics to return.

Default Fields:

impressions,reach,ad_name,account_currency,buying_type,campaign_id,campaign_name,clicks,conversion_rate_ranking,conversions,cpc,cpm,ctr,frequency,social_spend,spend,unique_clicks,unique_ctr

Default Cloud9QL:

select data;
select expand(data);

Common Use Cases

Track Ad Spend Over Time

select data;
select expand(data);
select date_start, campaign_name, spend, impressions, clicks, ctr
order by date_start desc;

Campaign Performance Comparison

select data;
select expand(data);
select campaign_name, sum(spend) as total_spend, sum(impressions) as total_impressions,
       sum(clicks) as total_clicks, avg(ctr) as avg_ctr
group by campaign_name
order by total_spend desc;

Cost Per Click Analysis

select data;
select expand(data);
select ad_name, spend, clicks, cpc
where clicks > 0
order by cpc asc;

Scheduling

Once configured, schedule your queries to run automatically (e.g., daily) to keep dashboards current. AgenticBI handles cursor-based pagination automatically through Facebook's paging.next URL.

Notes

  • AgenticBI uses Meta Graph API v24.0 (released October 2025).
  • Facebook access tokens obtained via OAuth are long-lived offline tokens.
  • API rate limits are managed automatically by AgenticBI's pagination engine.
  • You need a Facebook Business account with ad account access to use this connector.
  • For the latest available fields and metrics, refer to the Meta Marketing API documentation.