A small mara data integration pipeline that incrementally loads the files downloaded by the mara Facebook ads performance downloader into a PostgreSQL data warehouse and transforms the data into a dimensional schema.
The pipeline (defined in facebook_ads_performance_pipeline/init.py) creates a database schema fb_dim
that contains an ad_performance
fact table with the dimensions time
, ad
and device
:
This is an example row of the fact table:
select * from fb_dim.ad_performance where conversions > 0 order by random() limit 1;
-[ RECORD 1 ]------+------------------
day_fk | 20180924
ad_fk | 23844375245730149
device_fk | 1
impressions | 1226
inline_link_clicks | 47
spend | 33.47
conversions | 8
conversion_value | 1137.68
See Ads Insights - Parameters for a documentation of the metrics.
Add
-e git+git@github.com:mara/facebook-ads-performance-pipeline.git@1.0.0#egg=facebook_ads_performance_pipeline
to the requirements.txt
of your mara project. See the mara example project for details.
Make sure that your ETL contains the etl_tools/create_time_dimensions/ pipeline for creating the time.day
dimension.
Then add the pipeline to your ETL with
import facebook_ads_performance_pipeline
my_pipeline.add(facebook_ads_performance_pipeline.pipeline)