Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making changes to source Google Ads package to include conversion met… #59

Merged
merged 8 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 11 additions & 32 deletions .github/PULL_REQUEST_TEMPLATE/maintainer_pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,27 @@
**This PR will result in the following new package version:**
<!--- Please add details around your decision for breaking vs non-breaking version upgrade. If this is a breaking change, were backwards-compatible options explored? -->

**Please detail what change(s) this PR introduces and any additional information that should be known during the review of this PR:**
**Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:**
<!--- Copy/paste the CHANGELOG for this version below. -->

## PR Checklist
### Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
- [ ] dbt compile
- [ ] dbt run –full-refresh
- [ ] dbt run
- [ ] dbt test
- [ ] dbt run –vars (if applicable)
- [ ] dbt run –full-refresh && dbt test
- [ ] dbt run (if incremental models are present) && dbt test

Before marking this PR as "ready for review" the following have been applied:
- [ ] The appropriate issue has been linked and tagged
- [ ] You are assigned to the corresponding issue and this PR
- [ ] BuildKite integration tests are passing
- [ ] The appropriate issue has been linked, tagged, and properly assigned.
- [ ] All necessary documentation and version upgrades have been applied.
<!--- Be sure to update the package version in the dbt_project.yml, integration_tests/dbt_project.yml, and README if necessary. -->
- [ ] docs were regenerated (unless this PR does not include any code or yml updates).
- [ ] BuildKite integration tests are passing.
- [ ] Detailed validation steps have been provided below.

### Detailed Validation
Please acknowledge that the following validation checks have been performed prior to marking this PR as "ready for review":
- [ ] You have validated these changes and assure this PR will address the respective Issue/Feature.
- [ ] You are reasonably confident these changes will not impact any other components of this package or any dependent packages.
- [ ] You have provided details below around the validation steps performed to gain confidence in these changes.
Please share any and all of your validation steps:
<!--- Provide the steps you took to validate your changes below. -->

### Standard Updates
Please acknowledge that your PR contains the following standard updates:
- Package versioning has been appropriately indexed in the following locations:
- [ ] indexed within dbt_project.yml
- [ ] indexed within integration_tests/dbt_project.yml
- [ ] CHANGELOG has individual entries for each respective change in this PR
<!--- If there is a parallel upstream change, remember to reference the corresponding CHANGELOG as an individual entry. -->
- [ ] README updates have been applied (if applicable)
<!--- Remember to check the following README locations for common updates. →
<!--- Suggested install range (needed for breaking changes) →
<!--- Dependency matrix is appropriately updated (if applicable) →
<!--- New variable documentation (if applicable) -->
- [ ] DECISIONLOG updates have been updated (if applicable)
- [ ] Appropriate yml documentation has been added (if applicable)

### dbt Docs
Please acknowledge that after the above were all completed the below were applied to your branch:
- [ ] docs were regenerated (unless this PR does not include any code or yml updates)

### If you had to summarize this PR in an emoji, which would it be?
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ We are so excited you decided to contribute to the Fivetran community dbt packag
**PR Template**
- [Community Pull Request Template](?expand=1&template=pull_request_template.md) (default)

- [Maintainer Pull Request Template](?expand=1&template=maintainer_pull_request_template.md) (to be used by maintainers)
- [Maintainer Pull Request Template](?expand=1&template=maintainer_pull_request_template.md) (to be used by maintainers)
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ env/
target/
dbt_modules/
logs/
env/
dbt_packages/
package-lock.yml
package-lock.yml
integration_tests/package-lock.yml
.DS_Store
integration_tests/.DS_Store
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# dbt_google_ads_source v0.11.0

[PR #59](https://github.com/fivetran/dbt_google_ads_source/pull/59) includes the following updates:

## Feature Updates: Conversion Support!
- We have added the following source fields to each `stg_google_ads__<entity>_stats` model:
- `conversions`: The number of conversions you've received, across your conversion actions. Conversions are measured with conversion tracking and may include [modeled](https://support.google.com/google-ads/answer/10081327?sjid=12862894247631803415-NC) conversions in cases where you are not able to observe all conversions that took place. You can use this column to see how often your ads led customers to actions that you’ve defined as valuable for your business.
- `conversions_value`: The sum of monetary values for your `conversions`. You have to enter a value in the Google Ads UI for your conversion actions to make this metric useful.
- `view_through_conversions`: For video campaigns, view-through conversions tell you when an _impression_ of your video ad leads to a conversion on your site. The last impression of a video ad will get credit for the view-through conversion. An impression is different than a “view” of a video ad. A “view” is counted when someone watches 30 seconds (or the whole ad if it’s shorter than 30 seconds) or clicks on a part of the ad. A “view” that leads to a conversion is counted in the `conversions` column.
- In the event that you were already passing the above fields in via our [passthrough columns](https://github.com/fivetran/dbt_google_ads_source?tab=readme-ov-file#passing-through-additional-metrics), the package will dynamically avoid "duplicate column" errors.
> The above new field additions are 🚨 **breaking changes** 🚨 for users who were not already bringing in conversion fields via passthrough columns.

## Under the Hood
- Updated the package maintainer PR template.
- Created `google_ads_fill_pass_through_columns` and `google_ads_add_pass_through_columns` macros to ensure that the new conversion fields are backwards compatible with users who have already included them via passthrough fields.

## Contributors
- [Seer Interactive](https://www.seerinteractive.com/?utm_campaign=Fivetran%20%7C%20Models&utm_source=Fivetran&utm_medium=Fivetran%20Documentation)
- [@fivetran-poonamagate](https://github.com/fivetran-poonamagate)

# dbt_google_ads_source v0.10.1

[PR #54](https://github.com/fivetran/dbt_google_ads_source/pull/54) includes the following updates:
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ dispatch:
search_order: ['spark_utils', 'dbt_utils']
```

## Step 2: Install the package (skip if also using the `google_ads` transformation package)
If you are **not** using the [Google Ads transformation package](https://github.com/fivetran/dbt_google_ads), include the following package version in your `packages.yml` file. If you are installing the transform package, the source package is automatically installed as a dependency.
## Step 2: Install the package (skip if also using the `google_ads` transformation or `ad_reportin` combination package)
If you are **not** using the [Google Ads transformation package](https://github.com/fivetran/dbt_google_ads) or the [Ad Reporting combination package](https://github.com/fivetran/dbt_ad_reporting), include the following package version in your `packages.yml` file. If you are installing the transform package, the source package is automatically installed as a dependency.
> TIP: Check [dbt Hub](https://hub.getdbt.com/) for the latest installation instructions or [read the dbt docs](https://docs.getdbt.com/docs/package-management) for more information on installing packages.

```yml
packages:
- package: fivetran/google_ads_source
version: [">=0.10.0", "<0.11.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.11.0", "<0.12.0"] # we recommend using ranges to capture non-breaking changes automatically
```
## Step 3: Define database and schema variables
By default, this package runs using your destination and the `google_ads` schema. If this is not where your Google Ads data is (for example, if your google_ads schema is named `google_ads_fivetran`), add the following configuration to your root `dbt_project.yml` file:
Expand All @@ -65,7 +65,7 @@ Please be aware that the native `source.yml` connection set up in the package wi
To connect your multiple schema/database sources to the package models, follow the steps outlined in the [Union Data Defined Sources Configuration](https://github.com/fivetran/dbt_fivetran_utils/tree/releases/v0.4.latest#union_data-source) section of the Fivetran Utils documentation for the union_data macro. This will ensure a proper configuration and correct visualization of connections in the DAG.

### Passing Through Additional Metrics
By default, this package will select `clicks`, `impressions`, and `cost` from the source reporting tables to store into the staging models. If you would like to pass through additional metrics to the staging models, add the below configurations to your `dbt_project.yml` file. These variables allow for the pass-through fields to be aliased (`alias`) if desired, but not required. Use the below format for declaring the respective pass-through variables:
By default, this package will select `clicks`, `impressions`, `cost`, `conversions`, `conversions_value`, and `view_through_conversions` from the source reporting tables to store into the staging models. If you would like to pass through additional metrics to the staging models, add the below configurations to your `dbt_project.yml` file. These variables allow for the pass-through fields to be aliased (`alias`) if desired, but not required. Use the below format for declaring the respective pass-through variables:

>**Note** Please ensure you exercised due diligence when adding metrics to these models. The metrics added by default (taps, impressions, and spend) have been vetted by the Fivetran team maintaining this package for accuracy. There are metrics included within the source reports, for example metric averages, which may be inaccurately represented at the grain for reports created in this package. You will want to ensure whichever metrics you pass through are indeed appropriate to aggregate at the respective reporting levels provided in this package.

Expand All @@ -85,8 +85,9 @@ vars:
- name: "other_id"
alias: "another_id"
```

### Change the build schema
By default, this package builds the Google Ads staging models within a schema titled (`<target_schema>` + `_google_ads_source`) in your destination. If this is not where you would like your google_ads staging data to be written to, add the following configuration to your root `dbt_project.yml` file:
By default, this package builds the Google Ads staging models (10 views, 10 tables) within a schema titled (`<target_schema>` + `_google_ads_source`) in your destination. If this is not where you would like your google_ads staging data to be written to, add the following configuration to your root `dbt_project.yml` file:

```yml
models:
Expand All @@ -95,7 +96,7 @@ models:
```

### Change the source table references
If an individual source table has a different name than the package expects, add the table name as it appears in your destination to the respective variable:
If an individual source table has a different name than the package expects, add the table name as it appears in your destination to the respective variable. This is not available when running the package on multiple unioned connectors.
> IMPORTANT: See this project's [`dbt_project.yml`](https://github.com/fivetran/dbt_google_ads_source/blob/main/dbt_project.yml) variable declarations to see the expected names.

```yml
Expand Down Expand Up @@ -133,11 +134,10 @@ The Fivetran team maintaining this package _only_ maintains the latest version o
In creating this package, which is meant for a wide range of use cases, we had to take opinionated stances on a few different questions we came across during development. We've consolidated significant choices we made in the [DECISIONLOG.md](https://github.com/fivetran/dbt_google_ads_source/blob/main/DECISIONLOG.md), and will continue to update as the package evolves. We are always open to and encourage feedback on these choices, and the package in general.

## Contributions
A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions!
A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions!

We highly encourage and welcome contributions to this package. Check out [this dbt Discourse article](https://discourse.getdbt.com/t/contributing-to-a-dbt-package/657) to learn how to contribute to a dbt package!

# 🏪 Are there any resources available?
- If you have questions or want to reach out for help, please refer to the [GitHub Issue](https://github.com/fivetran/dbt_google_ads_source/issues/new/choose) section to find the right avenue of support for you.
- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our [Feedback Form](https://www.surveymonkey.com/r/DQ7K7WW).
- Have questions or want to be part of the community discourse? Create a post in the [Fivetran community](https://community.fivetran.com/t5/user-group-for-dbt/gh-p/dbt-user-group) and our team along with the community can join in on the discussion!
- If you would like to provide feedback to the dbt package team at Fivetran or would like to request a new dbt package, fill out our [Feedback Form](https://www.surveymonkey.com/r/DQ7K7WW).
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'google_ads_source'
version: '0.10.1'
version: '0.11.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
vars:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'google_ads_source_integration_tests'
version: '0.10.1'
version: '0.11.0'
profile: 'integration_tests'
config-version: 2

Expand All @@ -16,6 +16,11 @@ vars:
google_ads_campaign_stats_identifier: "campaign_stats_data"
google_ads_ad_group_criterion_history_identifier: "ad_group_criterion_history_data"

google_ads__account_stats_passthrough_metrics:
- name: conversions
- name: view_through_conversions
alias: view_through_conversions_aliased

seeds:
google_ads_source_integration_tests:
+column_types:
Expand Down
10 changes: 7 additions & 3 deletions macros/get_account_stats_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
{"name": "customer_id", "datatype": dbt.type_int()},
{"name": "date", "datatype": "date"},
{"name": "device", "datatype": dbt.type_string()},
{"name": "impressions", "datatype": dbt.type_int()}
{"name": "impressions", "datatype": dbt.type_int()},
{"name": "conversions", "datatype": dbt.type_int()},
{"name": "conversions_value", "datatype": dbt.type_int()},
{"name": "view_through_conversions", "datatype": dbt.type_int()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('google_ads__account_stats_passthrough_metrics')) }}
{# Doing it this way in case users were bringing in conversion metrics via passthrough columns prior to us adding them by default #}
{{ google_ads_add_pass_through_columns(base_columns=columns, pass_through_fields=var('google_ads__account_stats_passthrough_metrics'), except_fields=['conversions', "conversions_value", "view_through_conversions"]) }}

{{ return(columns) }}

{% endmacro %}
{% endmacro %}
10 changes: 7 additions & 3 deletions macros/get_ad_group_stats_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
{"name": "date", "datatype": "date"},
{"name": "device", "datatype": dbt.type_string()},
{"name": "id", "datatype": dbt.type_int()},
{"name": "impressions", "datatype": dbt.type_int()}
{"name": "impressions", "datatype": dbt.type_int()},
{"name": "conversions", "datatype": dbt.type_int()},
{"name": "conversions_value", "datatype": dbt.type_int()},
{"name": "view_through_conversions", "datatype": dbt.type_int()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('google_ads__ad_group_stats_passthrough_metrics')) }}
{# Doing it this way in case users were bringing in conversion metrics via passthrough columns prior to us adding them by default #}
{{ google_ads_add_pass_through_columns(base_columns=columns, pass_through_fields=var('google_ads__ad_group_stats_passthrough_metrics'), except_fields=['conversions', "conversions_value", "view_through_conversions"]) }}

{{ return(columns) }}

{% endmacro %}
{% endmacro %}
8 changes: 6 additions & 2 deletions macros/get_ad_stats_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
{"name": "date", "datatype": "date"},
{"name": "device", "datatype": dbt.type_string()},
{"name": "impressions", "datatype": dbt.type_int()},
{"name": "keyword_ad_group_criterion", "datatype": dbt.type_string()}
{"name": "keyword_ad_group_criterion", "datatype": dbt.type_string()},
{"name": "conversions", "datatype": dbt.type_int()},
{"name": "conversions_value", "datatype": dbt.type_int()},
{"name": "view_through_conversions", "datatype": dbt.type_int()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('google_ads__ad_stats_passthrough_metrics')) }}
{# Doing it this way in case users were bringing in conversion metrics via passthrough columns prior to us adding them by default #}
{{ google_ads_add_pass_through_columns(base_columns=columns, pass_through_fields=var('google_ads__ad_stats_passthrough_metrics'), except_fields=['conversions', "conversions_value", "view_through_conversions"]) }}
fivetran-jamie marked this conversation as resolved.
Show resolved Hide resolved

{{ return(columns) }}

Expand Down
8 changes: 6 additions & 2 deletions macros/get_campaign_stats_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
{"name": "date", "datatype": "date"},
{"name": "device", "datatype": dbt.type_string()},
{"name": "id", "datatype": dbt.type_int()},
{"name": "impressions", "datatype": dbt.type_int()}
{"name": "impressions", "datatype": dbt.type_int()},
{"name": "conversions", "datatype": dbt.type_int()},
{"name": "conversions_value", "datatype": dbt.type_int()},
{"name": "view_through_conversions", "datatype": dbt.type_int()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('google_ads__campaign_stats_passthrough_metrics')) }}
{# Doing it this way in case users were bringing in conversion metrics via passthrough columns prior to us adding them by default #}
{{ google_ads_add_pass_through_columns(base_columns=columns, pass_through_fields=var('google_ads__campaign_stats_passthrough_metrics'), except_fields=['conversions', "conversions_value", "view_through_conversions"]) }}

{{ return(columns) }}

Expand Down
8 changes: 6 additions & 2 deletions macros/get_keyword_stats_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
{"name": "customer_id", "datatype": dbt.type_int()},
{"name": "date", "datatype": "date"},
{"name": "device", "datatype": dbt.type_string()},
{"name": "impressions", "datatype": dbt.type_int()}
{"name": "impressions", "datatype": dbt.type_int()},
{"name": "conversions", "datatype": dbt.type_int()},
{"name": "conversions_value", "datatype": dbt.type_int()},
{"name": "view_through_conversions", "datatype": dbt.type_int()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('google_ads__keyword_stats_passthrough_metrics')) }}
{# Doing it this way in case users were bringing in conversion metrics via passthrough columns prior to us adding them by default #}
{{ google_ads_add_pass_through_columns(base_columns=columns, pass_through_fields=var('google_ads__keyword_stats_passthrough_metrics'), except_fields=['conversions', "conversions_value", "view_through_conversions"]) }}

{{ return(columns) }}

Expand Down
Loading