pawelngei / dbt_google_ads

Fivetran data transformations for Google Ads built using dbt.

Home Page:https://fivetran.github.io/dbt_google_ads/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Apache License dbt logo and version

Google Ads

This package models Google Ads data from Fivetran's connector.

The main focus of the package is to transform the core ad object tables into analytics-ready models, including an 'ad adapter' model that can be easily unioned in to other ad platform packages to get a single view. This is especially easy using our Ad Reporting package.

Models

This package contains transformation models, designed to work simultaneously with our Google Ads source package and our multi-platform Ad Reporting package. A dependency on the source package is declared in this package's packages.yml file, so it will automatically download when you run dbt deps. The primary outputs of this package are described below.

Please note this package allows for either Adwords API or Google Ads API connector configuration. For specific API configuration instructions refer to the Google Ads source package. Additionally, not all final models will be generated based off the API being used. Refer to the table below for an understanding of which models will be created per API.

model description compatible API
google_ads__url_ad_adapter Each record represents the daily ad performance of each URL in each ad group, including information about the used UTM parameters. Adwords API and Google Ads API
google_ads__criteria_ad_adapter Each record represents the daily ad performance of each criteria in each ad group. Adwords API Only
google_ads__click_performance Each record represents a click, with a corresponding Google click ID (gclid). Adwords API Only

Installation Instructions

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:
  - package: fivetran/google_ads
    version: [">=0.4.0", "<0.5.0"]

Configuration

As previously mentioned, package allows users to leverage either the Adwords API or the Google Ads API. You will be able to determine which API your connector is using by navigating within your Fivetran UI to the setup tab -> edit connection details link -> and reference the API configuration used.

Google Ads API Configuration

If your connector is setup using the Google Ads API then you will need to configure your dbt_project.yml with the below variable:

# dbt_project.yml

...
config-version: 2

vars:
    api_source: google_ads  ## adwords by default

Adwords API Configuration

If your connector is setup using the Adwords API then you will need to pull the following custom reports through Fivetran:

  • Destination Table Name: final_url_performance

  • Report Type: FINAL_URL_REPORT

  • Fields:

    • AccountDescriptiveName
    • AdGroupId
    • AdGroupName
    • AdGroupStatus
    • CampaignId
    • CampaignName
    • CampaignStatus
    • Clicks
    • Cost
    • Date
    • EffectiveFinalUrl
    • ExternalCustomerId
    • Impressions
  • Destination Table Name: criteria_performance

  • Report Type: CRITERIA_PERFORMANCE_REPORT

  • Fields:

    • AccountDescriptiveName
    • AdGroupId
    • AdGroupName
    • AdGroupStatus
    • CampaignId
    • CampaignName
    • CampaignStatus
    • Clicks
    • Cost
    • Criteria
    • CriteriaDestinationUrl
    • CriteriaType
    • Date
    • ExternalCustomerId
    • Id
    • Impressions
  • Destination Table Name: click_performance

  • Report Type: CLICK_PERFORMANCE_REPORT

  • Fields:

    • AccountDescriptiveName
    • AdGroupId
    • AdGroupName
    • AdGroupStatus
    • CampaignId
    • CampaignName
    • CampaignStatus
    • Clicks
    • CriteriaId
    • Date
    • ExternalCustomerId
    • GclId

The package assumes that the corresponding destination tables are named final_url_performance, criteria_performance, and click_performance respectively. If these tables have different names in your destination, enter the correct table names in the google_ads__final_url_performance, google_ads__click_performance, and google_ads__criteria_performance variables so that the package can find them:

# dbt_project.yml

...
config-version: 2

vars:
    google_ads__final_url_performance: "{{ ref('a_model_you_wrote') }}"
    google_ads__click_performance: adwords.click_performance_report

Source Schema is Named Differently

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

# dbt_project.yml

...
config-version: 2

vars:
    google_ads_source:
      google_ads_schema: your_schema_name
      google_ads_database: your_database_name 

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

Optional Configurations

Passing Through Additional Metrics

By default, this package will select clicks, impressions, and cost from the source reporting tables to store into the ad adapter models. If you would like to pass through additional metrics to the ad adapter models, add the following configuration to your dbt_project.yml file:

# dbt_project.yml

...
vars:    
    # If you're using the Adwords API source
    google_ads__url_passthrough_metrics: ['the', 'list', 'of', 'metric', 'columns', 'to', 'include'] # from adwords.final_url_performance
    google_ads__criteria_passthrough_metrics: ['the', 'list', 'of', 'metric', 'columns', 'to', 'include'] # from adwords.criteria_performance
    # If you're using the Google Ads API source
    google_ads__ad_stats_passthrough_metrics: ['the', 'list', 'of', 'metric', 'columns', 'to', 'include'] # from google_ads.ad_stats

Changing the Build Schema

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

# dbt_project.yml

...
models:
  google_ads:
    +schema: my_new_schema_name # leave blank for just the target_schema
  google_ads_source:
    +schema: my_new_schema_name # leave blank for just the target_schema

Database Support

This package has been tested on BigQuery, Snowflake, Redshift, Postgres, and Databricks.

Databricks Dispatch Configuration

dbt v0.20.0 introduced a new project-level dispatch configuration that enables an "override" setting for all dispatched macros. If you are using a Databricks destination with this package you will need to add the below (or a variation of the below) dispatch configuration within your dbt_project.yml. This is required in order for the package to accurately search for macros within the dbt-labs/spark_utils then the dbt-labs/dbt_utils packages respectively.

# dbt_project.yml

dispatch:
  - macro_namespace: dbt_utils
    search_order: ['spark_utils', 'dbt_utils']

Contributions

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.

Resources:

About

Fivetran data transformations for Google Ads built using dbt.

https://fivetran.github.io/dbt_google_ads/

License:Apache License 2.0