Skip to content

HousewareHQ/dbt_facebook_ads_metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Facebook Ads Metrics dbt Package (Docs)

#Pre-Reqs! For the package to work, you need to import basic ad report while ETLing Ad data with Fivetran

🛑 Few things to keep in mind

These packages are under active development and are expected to change with dbt metrics as it evolves over time. As of now, dbt metrics requires users to define models to calculate metrics and these models are persisted on the warehouse. Keeping this in mind, we have currently modelled our packages such that metrics and the models calculating these metrics have a 1:1 mapping, which is why you will see multiple metrics for the same conceptual metric entity accounting for different time grains and dimensions. In future, with the roll out of dbt Server and evolution of dbt metrics, we expect to streamline our packages to remove these redundancies.

The metrics in these packages are transformed on top of source data ETL'd via Fivetran to your warehouse. Make sure you have connected your SaaS source with Fivetran for the packages to work properly.

📣 What does this dbt package do?

This package provides pre-built metrics for Facebook ads data from Fivetran's connector. It uses data in the format described by this ERD.

This package enables you to access commonly used metrics on top of Facebook Ads Data

Metrics

This package contains transformed models built on top of Facebook_ads_source package. A dependency on the source packages is declared in this package's packages.yml file, so it will automatically download when you run dbt deps.

The metrics offered by this package are described below. Note that all the metrics contain extended metrics for segmentation based on campaigns and adsets.

metric description
facebook_ads__monthly_ads Number of ads running monthly
facebook_ads__monthly_ad_sets Number of ad_sets running monthly
facebook_ads__monthly_campaigns Number of campaigns running monthly
facebook_ads__monthly_impressions Monthly impressions per ad
facebook_ads__monthly_ad_clicks Monthly clicks on an ad
facebook_ads__monthly_ad_spend Monthly spend on ads
facebook_ads__monthly_cost_per_click monthly cost per ad click
facebook_ads__monthly_cost_per_impression Monthly cost per ad impression.
facebook_ads__monthly_click_through_rate Monthly rate of users clicking on ad after viewing.
facebook_ads__monthly_conversions Monthly number of ad conversions.
facebook_ads__monthly_cost_per_conversion Monthly cost per ad conversion.

🎯 How do I use the dbt package?

Step 1: Prerequisites

To use this dbt package, you must have the following:

  • At least one Fivetran Facebook Ads connector syncing data into your destination.
  • A BigQuery, Snowflake, Redshift, or PostgreSQL destination.

Step 2: Install the package

Check dbt Hub for the latest installation instructions, or read the dbt docs for more information on installing packages.

Include in your packages.yml

packages:
  - git: "https://github.com/HousewareHQ/dbt_facebook_ads_metrics.git"
    revision: v0.1.0

Step 3: Define database and schema variables

By default, this package will look for your Facebook Ads data in the fivetran_facebook_ads schema of your target database. If this is not where your Facebook Ads data is, please add the following configuration to your dbt_project.yml file:

# dbt_project.yml

...
config-version: 2

vars:
  facebook_ads_database: your_database_name
  facebook_ads_schema: your_schema_name

For additional configurations for the source models, please visit the Facebook Ads source package.

(Optional) Step 4: Change build schema

By default this package will build the Facebook Ads staging models within a schema titled (<target_schema> + _stg_facebook_ads) and the Facebook Ads metrics within a schema titled (<target_schema> + _facebook_ads_metrics) in your target database. If this is not where you would like your modeled Intercom data to be written to, add the following configuration to your dbt_project.yml file:

# dbt_project.yml

...
models:
  facebook_ads_metrics:
    +schema: my_new_schema_name # leave blank for just the target_schema
  facebook_ads_source:
    +schema: my_new_schema_name # leave blank for just the target_schema

🗄 Which warehouses are supported?

This package has been tested on BigQuery, Snowflake.

🙌 Can I contribute?

Additional contributions to this package are very welcome! Please create issues or open PRs against main. Check out this post on the best workflow for contributing to a package.

🏪 Are there any resources available?