Facebook Ads
Table of Contents
The tap-facebook
Meltano extractor pulls data from Facebook Ads that can then be sent to a destination using a loader.
-
- Repository: https://github.com/singer-io/tap-facebook
-
-
-
-
-
-
-
- Maintainer: Stitch
- Meltano Stats (across all plugin variants):
-
-
Alternative variants #
Multiple
variants
of tap-facebook
are available.
This document describes the default singer-io
variant,
which is recommended for new users.
Alternative variants are:
Getting Started #
Prerequisites #
If you haven't already, follow the initial steps of the Getting Started guide:
Installation and configuration #
-
Add the
tap-facebook
extractor to your project usingmeltano add
:meltano add extractor tap-facebook
-
Configure the settings below using
meltano config
.
Next steps #
Follow the remaining steps of the Getting Started guide:
- Select entities and attributes to extract
- Add a loader to send data to a destination
- Run a data integration (EL) pipeline
Capabilities #
These capabilities can also be overriden
by specifying the capabilities
key in your meltano.yml
file.
Settings #
tap-facebook
requires the
configuration
of the following settings:
The settings for extractor tap-facebook
that are known to Meltano are documented below.
To quickly find the
setting you're looking for, use the Table of Contents at
the top of the page.
You can override these
settings or specify additional
ones in your meltano.yml
by adding the settings
key.
Please consider adding any settings you have defined locally to this definition on MeltanoHub by making a pull
request to the
YAML file
that defines the settings for this
extractor.
Account ID (account_id
)
#
-
Environment variable:
TAP_FACEBOOK_ACCOUNT_ID
Your Facebook Ads Account ID
How to get #
To get your Account ID:
- Visit the Facebook Ads Manager: https://www.facebook.com/adsmanager/
- Log in if you haven’t already.
- Make sure the correct account is selected in the top left corner.
- You will see the Account ID displayed inside the selector. You can also find it in the URL, after
?act=
and ahead of any additional parameters starting with&
:
Examples:
-
URL:
https://www.facebook.com/adsmanager/manage/campaigns?act=593385444078559
Account ID:
593385444078559
-
URL:
https://business.facebook.com/adsmanager/manage/campaigns?act=791728544625001&business_id=172253903856261
Account ID:
791728544625001
How to use #
Manage this setting using
meltano config
or an
environment variable:
meltano config tap-facebook set account_id <account_id>
export TAP_FACEBOOK_ACCOUNT_ID=<account_id>
Access Token (access_token
)
#
-
Environment variable:
TAP_FACEBOOK_ACCESS_TOKEN
User Token generated by Facebook OAuth handshake
How to get #
Create App #
First, you will need to create a Facebook App through the Developer Portal.
::: tip Don’t feel like going through the Facebook App setup process?
Once you authorize Meltano to access your Facebook Ads data, Facebook will generate an access token and provide it to Meltano OAuth Service. The OAuth Service will not store or use the token, and will only display it to you once so that you can copy and paste it into your local Meltano configuration. :::
- Go to https://developers.facebook.com/.
- Log into Facebook if you haven’t already. Make sure that your account is an Admin of the Ads Account you will be pulling data from.
- Convert your Facebook account to a Developer Account if you haven’t done so already. This will not affect your personal Facebook profile, but will give you access to Facebook’s developer tools.
- Click “My Apps” in the top right, and choose “Create App”.
- In the modal that appears, enter a “Display Name” of your choosing. Since you will only use this app to generate an Access Token for your own use, the actual display name does not matter too much.
- Enter your email address under “Contact Email” if it is not yet populated automatically.
- Click “Create App ID”.
- Under “Add a Product”, find “Marketing API”, and click “Set Up”.
Generate Access Token #
Now that your app has been created and the Marketing API product has been enabled, we can generate an access token.
- In the sidebar on the left, expand “Marketing API” if it isn’t expanded already.
- Under “Marketing API”, click “Tools”.
- Select
ads_management
,ads_read
, andmanage_pages
under “Select Token Permissions”. - Click “Get Token”.
- Copy the token that appears in the field.
This is the Access Token you will provide to Meltano.
Connect the App #
After generating the access token, your app will need to be connected to the ad account within Facebook Business Manager. Navigate to Business Manager > Accounts > Apps > Connected Assets > Add Assets to add the access token.
Token Expiration #
Tokens generated using this method are only valid for 60 days by default. When the token expires, Meltano will no longer be able to automatically update your Facebook Ads data, and you will need to generate a new token and update the extractor configuration.
To find out exactly when this token will expire, you can use the Access Token Debugger:
- Go to https://developers.facebook.com/tools/debug/accesstoken/.
- Paste the token into the field at the top.
- Click “Debug” on the right.
- Look for the value under “Expires”.
To prevent any interruption of your data pipeline, we recommend that you generate and configure a new token before the currently configured one expires:
- Go to https://developers.facebook.com/
- Log into Facebook if you haven’t already.
- Click “My Apps” in the top right, and select the app you created earlier.
- Follow the steps under “Generate Access Token” above.
How to use #
Manage this setting using
meltano config
or an
environment variable:
meltano config tap-facebook set access_token <access_token>
export TAP_FACEBOOK_ACCESS_TOKEN=<access_token>
Start Date (start_date
)
#
-
Environment variable:
TAP_FACEBOOK_START_DATE
Determines how much historical data will be extracted. Please be aware that the larger the time period and amount of data, the longer the initial extraction can be expected to take.
How to use #
Manage this setting using
meltano config
or an
environment variable:
meltano config tap-facebook set start_date YYYY-MM-DDTHH:MM:SSZ
export TAP_FACEBOOK_START_DATE=YYYY-MM-DDTHH:MM:SSZ
End Date (end_date
)
#
-
Environment variable:
TAP_FACEBOOK_END_DATE
Date up to when historical data will be extracted.
How to use #
Manage this setting using
meltano config
or an
environment variable:
meltano config tap-facebook set end_date YYYY-MM-DDTHH:MM:SSZ
export TAP_FACEBOOK_END_DATE=YYYY-MM-DDTHH:MM:SSZ
Insights Buffer Days (insights_buffer_days
)
#
-
Environment variable:
TAP_FACEBOOK_INSIGHTS_BUFFER_DAYS
- Default:
0
How many Days before the Start Date to fetch Ads Insights for
How to use #
Manage this setting using
meltano config
or an
environment variable:
meltano config tap-facebook set insights_buffer_days 0
export TAP_FACEBOOK_INSIGHTS_BUFFER_DAYS=0
Include Deleted Objects (include_deleted
)
#
-
Environment variable:
TAP_FACEBOOK_INCLUDE_DELETED
Determines if it should include deleted objects or not.
How to use #
Manage this setting using
meltano config
or an
environment variable:
meltano config tap-facebook set include_deleted true
export TAP_FACEBOOK_INCLUDE_DELETED=true
Looking for help? #
If you're having trouble getting the
tap-facebook
extractor to work, look for an
existing issue in its repository, file a new issue,
or
join the Meltano Slack community
and ask for help in the #plugins-general
channel.
Found an issue on this page? #
This page is generated from a YAML file that you can contribute changes to. Edit it on GitHub!