This project gives you ability to export data from Facebook/Meta Business to BigQuery.
BigQuery:
- Create a dataset in your BigQuery project;
- Add a table with schema provided in
insights_table.json
file; - Create a service account and save it as a
service-account.json
file connected to BigQuery API.
How to create a table in the UI:
Facebook:
- Create a project at https://developers.facebook.com with enabled Marketing API
Init an env using Poetry or another tool, create own config.py
from config.py.example
and run the script:
poetry install
poetry shell
cp config.py.example config.py
python export_insights.py
After running the script you must see something like this:
That's it. Enjoy!
- Only one SQL execution at the end of the script or after processing each campaign
-
MERGE
operation, with a staged table, #1