Facebook Ads

Facebook Ads is a service promoting customer products, services, websites, etc. from Facebook.

Data integration: Skyvia supports importing data to and from Facebook Ads, exporting Facebook Ads data to CSV files, replicating Facebook Ads data to relational databases, and synchronizing Facebook Ads data with other cloud apps and relational databases.

Backup: Skyvia Backup does not support Facebook Ads backup.

Query: Skyvia Query supports Facebook Ads.

Establishing Connection

To create a connection with Facebook Ads, sign in with Facebook Ads and specify the Ad Account Id.

Getting Credentials

You can find the Ad Account Id in your Facebook Ads Manager. The Ad Account Id value is located above the search and filter bar, in the account dropdown menu or in the page URL.

Connection Editor window

Creating Connection

To connect to Facebook Ads, perform the following steps:

Connection Editor window

  1. Click Sign In with Facebook.

  2. Enter your facebook credentials and click Log In.

    Facebook Sign In window

  3. Enter your Ad Account Id

Additional Connection Parameters

View Attribution Window

Specifies how many days to go back from the last sync time when fetching conversions based on ad impressions during Incremental Replication. Default value is 7 days.

Click Attribution Window

Specifies how many days to go back from the last sync time when fetching conversions based on ad clicks during Incremental Replication. Default value is 1 Day.

Include Incomplete Data in Reports

Enables including current days and months in Daily*...*Insights and Monthly*...*Insights reports. Data in reports might be incomplete. Default value is true.

Connector Specifics

Object Peculiarities

There are two types of objects in Facebook Ads: standard objects and *Insights objects.

Insights Objects

Objects with *Insights suffix in their names are the metrics for the random period from DateStart to DateStop. Default reporting period is last 36 months up to and including the current date.

Objects with Monthly*...*Insights names are the metrics for the completed calendar months. Default reporting period is last 36 full months (includes only the months whose first date falls within this period).

Objects with Daily*...*Insights names are the metrics for the completed days. Default reporting period is 6 months.

By default daily and monthly reports include data for the current periods in the query results and might be incomplete. Disable the Allow Incomplete Data in Reports parameter in the connection to include only the complete days or months. To set a custom period in daily or monthly report, add filters by the DateStart field with the following operators >=, >, <=, <.

For example, to get data for the last year in a daily report, you can add the following filters:
SELECT * FROM DailyAccountInsights WHERE DateStart >= '2025-03-01' and DateStart < '2026-03-01'

Breakdowns

When you query the *Insights objects, you can group the query results data by one or several compatible breakdowns. Each breakdown corresponds to an enum value in the Breakdowns field. The Breakdowns field lets you choose how your data should be grouped. Skyvia represents it as a field for filtering, but it doesn’t work like a regular SQL filter. Instead, it reorganizes the query results based on one or more selected breakdowns. When you use filter by the Breakdowns field, you may see more rows, your metric values are recalculated for each group.

For example, to group the campaign analytics by devices, we use the following query:

1
2
3
SELECT CampaignId, ImpressionDevice, Clicks, Impressions, Breakdowns
FROM CampaignInsights
WHERE Breakdowns = '["ImpressionDevice"]'

Make sure you use native filters when querying the *Insights objects with breakdowns. Otherwise, data will not be grouped.

The ActionBreakdowns field works similarly to Breakdowns, but it affects only action-related metric fields such as Actions, Conversions, and associated fields.

The list of available breakdowns is the following:

Type Breakdown value
General AdFormatAsset, Age, AppId,
BodyAsset,
CallToActioAsset, CoarseConversionValue, ConversionDestination, Country,
DescriptionAsset, DevicePlatform, Dma,
FidelityType, FrequencyValue,
Gender,
HourlyStatsAggregatedByAdvertiserTimeZone, HourlyStatsAggregatedByAudienceTimeZone, Hsid,
ImageAsset, ImpressionDevice, IsConversionIdModeled,
LandingDestination, LinkUrlAsset,
MarketingMessagesBtnName, MdsaLandingDestination, MediaAassetUrl, MediaCreator, MediaDestinationUrl, MediaFormat, MediaOriginUrl, MediaTextContent, Mmm,
PlacePageId, PlatformPosition, PostbackSequenceIndex, ProductId, PublisherPlatform,
Redownload, Region,
SkanCampaignId, SkanConversionId, SkanVersion, StandardEventContentType,
TitleAsset,
VideoAsset
Action breakdowns ActionCanvasComponentName, ActionCarouselCardId, ActionCarouselCardName, ActionDestination, ActionDevice, ActionReaction, ActionTargetId, ActionType, ActionVideoSound, ActionVideoType,
ConversionDestination,
MatchedPersonaId, MatchedPersonaName,
SignalSourceBucket, StandardEventContentType

Campaigns

Campaigns in the Draft status are not displayed in the query results by default.

Filtering Specifics

Facebook Ads API supports the following native filters for the *Insights objects:

Field Operator
AuctionBid, AuctionCompetitiveness, AuctionMaxCompetitorBid, CanvasAvgViewPercent, CanvasAvgViewTime, Clicks, CostPerDdaCountbyConvs, CostPerEstimatedAdRecallers, CostPerInlineLinkClick, CostPerInlinePostEngagement, CostPerUniqueClick, CostPerUniqueInlineLinkClick, Cpc, Cpm, Cpp, Ctr, DdaCountbyConvs, EstimatedAdRecallers, Frequency, Impressions, InlineLinkClickCtr, InlineLinkClicks, InlinePostEngagement, Instant_experience_outbound_clicks, InstantExperienceClicksToOpen, InstantExperienceClicksToStart, Reach, Spend, UniqueCtr, UniqueInlineLinkClicks, UniqueLinkClicksCtr >, >=, <, <=, IN, NOT IN
ActionBreakdowns, Breakdowns, ReportTime =
DateStart in the Daily*...*Insights and Monthly*...*Insights objects =, >, >=, <, <=
DateStart, DateStop in the *Insights objects =

For other Facebook Ads objects the native filters are the following:

Object Field
Campaigns Id, Name, Objective, BuyingType, SpendCap, CreatedTime, EffectiveStatus, UpdatedTime
AdSets Id, Name, CampaignId, BillingEvent, OptimizationGoal, BidAmount, LifetimeBudget, DailyBudget, CreatedTime, UpdatedTime
Ads Id, Name, CampaignId, AdSetId, BidAmount, CreatedTime, UpdatedTime
AdCreatives, AdVideos, AdImages Id
FormLeads CreatedTime
Audiences Id, Subtype

DML Operations Support

Operation Object
INSERT, UPDATE, DELETE Campaigns, AdSets, Ads
INSERT, DELETE AdImages, AdVideos
INSERT LeadgenForms

Incremental Replication and Synchronization

Skyvia supports Replication with Incremental Updates for the following Facebook Ads objects:

AdImages, Ads, AdSets, AdVideos, Audiences, Campaigns, DailyAccountInsights,DailyAdInsights, DailyAdSetInsights, DailyCampaignInsights, FormLeads, LeadgenForms, MonthlyAccountInsights, MonthlyAdInsights,MonthlyAdSetInsights, MonthlyCampaignInsights.

Skyvia detects only new records and doesn't track the updated records for the FormLeads and LeadgenForms objects.

By default, Skyvia replicates Monthly*...*Insights data for the last 36 months and Daily*...*Insights data — for the last 6 months from the initial replication run. To replicate daily reports for earlier periods, you can set the LastSyncTime parameter to the needed start date before the initial replication run.

Skyvia supports Synchronization for the following Facebook Ads objects: Ads, AdSets, Campaigns.

Retrospective Update

As the attribution window for Replication, Skyvia takes the highest value among the Click Attribution Window and View Attribution Window parameters.

Objects that support retrospective update:

  • Daily*...*Insights objects.
  • Monthly*...*Insights in case when attribution window is greater than 28 days.

See Retrospective Update for more information.

Stored Procedures

Skyvia represents some of the supported Facebook Ads features as stored procedures. You can call a stored procedure, for example, as a text of the command in the ExecuteCommand action in a Target component of a Data Flow or in Query.

AddUsersToAudience

Use this stored procedure to add users to an audience that accepts different formats of user data - phones, name/surname, MADID, key combinations, etc. It passes values to Facebook as is. Thus, you need to hash the data using the SHA256 algorithm after normalization before passing it to the procedure. Here are examples of calling this procedure:

CALL AddUsersToAudience('120330000000000000', 'EMAIL_SHA256', '["836f82db99121b3481011f16b49dfa5fbc714a0d1b1b9f784a1ebbbf5b39577f", "f2d1f1c853fd1f4be1eb5060eaae93066c877d069473795e31db5e70c4880859"]');

CALL AddUsersToAudience('120330000000000000', '["EMAIL", "FN", "LN"]', '[["<sha256 email>", "<sha256 first name>", "<sha256 last name>"], ["<sha256 email>", "", ""]]');

PARAMETER NAME DESCRIPTION
AudienceId Facebook Ads Audience identifier. This parameter is required.
Schema Schema of the data to be passed to Facebook. It can be a string with the name of the predefined schema (for example, PHONE, EMAIL_SHA256, etc.), or an array of strings with the names of the fields. This parameter is required.
Data JSON array of values to be passed to Facebook. The data must be normalized before passing it to the procedure, including hashing the personal data using the SHA256 algorithm. This parameter is required.
IsRaw A flag that indicates whether the data is raw (not normalized and not hashed)
Session A unique session identifier
DataSource A source of the data
AppIds A comma-separated list of Facebook Ads application identifiers
PageIds A comma-separated list of Facebook Ads page identifiers
Tags Array of JSON objects
CustomFieldValues Array of JSON objects

The procedure returns the following result fields:

Field Name Data Type Description
AudienceId String The audience that was used to add users
SessionId String A unique session identifier used to add users
NumReceived Int32 Number of submitted user entries received by Facebook Ads for the session. This is not a count of matched audience members.
NumInvalidEntries Int32 Number of entries reported as invalid by Facebook Ads.
InvalidEntrySamples String Samples of invalid entries returned by Facebook Ads.

AddUserEmailsToAudience

Use this stored procedure to add users to an existing Facebook Ads custom audience using a single plain email address or a JSON array of plain email addresses. Skyvia automatically trims leading and trailing whitespace, converts the addresses to lowercase, hashes them with SHA-256, and sends the hashes to Facebook Ads using the EMAIL_SHA256 schema. Here are examples of calling this procedure:

CALL AddUserEmailsToAudience('120330000000000000', '["john.doe@example.com", "Jane.Smith@Example.com "]');

CALL AddUserEmailsToAudience('120330000000000000', 'john.doe@example.com');

PARAMETER NAME DESCRIPTION
AudienceId Facebook Ads Audience identifier. This parameter is required.
Emails Emails of the users to be added to the audience. This parameter is required.

The procedure returns the following result fields:

Field Name Data Type Description
AudienceId String The audience that was used to add users
SessionId String A unique session identifier used to add users
NumReceived Int32 Number of submitted user entries received by Facebook Ads for the session. This is not a count of matched audience members.
NumInvalidEntries Int32 Number of entries reported as invalid by Facebook Ads.
InvalidEntrySamples String Samples of invalid entries returned by Facebook Ads.

Supported Actions

Skyvia supports all the common actions for Facebook Ads.