In order for Keboola to be able to get your data, we need two things, the page id, and your account token.
To get the account token:
1. Log into your facebook account that has the administrative privileges to the page you would like to track stats on
2. Follow the link here and copy the token. Give this token to your Keboola Consultant.
**Note** Facebook tokens expire every 2 months. Unfortunately there is no way around this so far. You will need to reauthorize KBC using this link every 2 months.
To get the page id:
1. Go to your facebook page's URL. For example, if you are getting stats for the fan page "Facebook", this is the page's URL you need.
2. Copy and paste the link using this website. (For example, use the url for the facebook link above, and paste it in the website referenced).
3. Copy and give this page id to your Keboola Consultant for each page id that you want the stats for.
Never expiring access token
This description did work to change access token from expiring at some point in time to never expiring.
https://www.rocketmarketinginc.com/blog/get-never-expiring-facebook-page-access-token/ (Check updated 2016 version)
RECREATING STANDARD FACEBOOK REPORTS VIA API
For this project we were required to recreate standard Facebook reports by extracting data through API.
List of metrics requested by customer and their API equivalents are in a file attached (Facebook standard reports API).
Facebook Graph API descriptions could be found by the link:
* This guide is written for Version 2.8. Some metrics will require mention of a version in a call.
All documentation about Keboola Facebook extractor is kept here:
In this guide only steps for a particular project described.
Facebook extractor configurations are kept in csv tables in sys.c-ex-facebook bucket. In order to create a Facebook extractor, first need to have config tables in the storage to refer to.
First table would be authorization config. Table will be names accounts and have next columns:
Order (just 1 if one account), id (FB account id), name (FB account name), token (authorization token), valid (put 1 for valid), user (id of user that authorized access to account). Full instructions on Keboola wiki:
Next we create config tables for extractors. We used two types of data imports - regular and pivoted. Regular would provide table with metrics as rows - there would be a column Metric and each record will specify metric and have one value. Pivoted calls return tables with metrics as columns - there will be a column for each metric where each row will have one value. Pivoted tables are much easier to work with so we tried to use as many metrics for Pivoted calls as possible, but it was not always possible (specifically for calls that return arrays of values). More description on Wiki:
In our project we had three configurations:
insightsPages_pivoted, insightsPosts_pivoted, insightsPosts
All three configurations attached. To review them use resources mentioned in the top of this guide.
For every configuration in sys bucket (except accounts) you will need to register a Facebook extractor. To do so you need to do a POST call to:
In the header enter key “X-StorageApi-Token” and Keboola storage token as value.
In the body:
For configurationId value enter name of a table with config in sys bucket. Value for name will be the name of your new extractor.
Once extractor created - you may change content of config table as many times as needed loading into the same table.
It is possible to import historical data for metrics that have “day”, “week”, “days_28”, “month” parameters available. We haven’t found a way to get data for “lifetime” metrics.
In order to restore history you need to make a POST call:
Config is the name of needed extractor configuration table in sys bucket.
Same call could be used for any other additional parameters by adding them to the body of the call.
When all tables are imported to the Storage, all you need is put data together in a way your customer prefers.
Take a look at the attached csv's for examples of configurations. This is an exhaustive list of metrics around posts and pages (and videos in particular) and should help you a long way.
Keboola WIKI > Keboola Connection (KBC) > 2. Using KBC > 2a) Extractors > User Articles >