Skip to content

Commit

Permalink
Add conversions (#34)
Browse files Browse the repository at this point in the history
* Add conversions

* docs

* docs

* update seed files

* schema

* passthrough exclusion changes

* regen docs, add all conversions/conversions value in, models

* gitignore

* remove ds store files

* add ds store back to gitignore after deleting files

* polish

* polish

* updates

* changelog

* headers

* note about source package dep

* added commented out conversion metrics to consistency tests for future use

* update package ref for release

---------

Co-authored-by: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
  • Loading branch information
fivetran-avinash and fivetran-jamie authored Oct 21, 2024
1 parent 0563671 commit e64e8a9
Show file tree
Hide file tree
Showing 34 changed files with 4,149 additions and 3,382 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ dbt_modules/
logs/
package-lock.yml
dbt_packages/
.DS_Store
.DS_store
integration_tests/.DS_store
.buildkite/.DS_store
.github/.DS_store
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# dbt_microsoft_ads v0.9.0
[PR #34](https://github.com/fivetran/dbt_microsoft_ads/pull/34) includes the following updates:

## Feature Updates: Conversion Metrics
- We have added the following source fields to each `microsoft_ads` end model:
- `conversions`: Number of conversions, measured by completion of an action by a customer after viewing your ad.
- `conversions_value`: The revenue reported by the advertiser as a result of the `conversions` figure.
- `all_conversions`: Number of *[all](https://learn.microsoft.com/en-us/advertising/reporting-service/conversionperformancereportcolumn?view=bingads-13#allconversions)* conversions, measured by completion of an action by a customer after viewing your ad. This field differs from `conversions` in that it includes conversions associated with a conversion goal in which the [ExcludeFromBidding](https://learn.microsoft.com/en-us/advertising/campaign-management-service/conversiongoal?view=bingads-13#excludefrombidding) Microsoft Ads property is set to `true`.
- `all_conversions_value` (except `microsoft_ads__account_report`): The revenue reported by the advertiser as a result of the `all_conversions` figure. This field differs from the default `conversions_value` field in that it includes revenue associated with a conversion goal in which the [ExcludeFromBidding](https://learn.microsoft.com/en-us/advertising/campaign-management-service/conversiongoal?view=bingads-13#excludefrombidding) Microsoft Ads property is set to `true`.
> The above new field additions are **breaking changes**.
## Under the Hood
- Created `microsoft_ads_persist_pass_through_columns` macro to ensure that the new conversion fields are backwards compatible for users who have already included them via passthrough fields.
- Added integrity and consistency validation tests within `integration_tests` folder for the transformation models (to be used by maintainers only).
- Updated seed files with new fields to test and validate on local data, provided specific casting to numeric (for currency) and integers.

## Documentation Update
- Updated `microsoft_ads.yml` with new fields mentioned above.

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

# dbt_microsoft_ads v0.8.0

[PR #32](https://github.com/fivetran/dbt_microsoft_ads/pull/32) includes the following updates:
Expand Down
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,17 @@ dispatch:
search_order: ['spark_utils', 'dbt_utils']
```
### Step 2: Install the package (skip if using Ad Reporting combo package)
### Step 2: Install the package (skip if using `ad_reporting` combo package)
If you are NOT using the [Ad Reporting combination package](https://github.com/fivetran/dbt_ad_reporting), include the following microsoft_ads package version in your `packages.yml` file:
> 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.
```yaml
packages:
- package: fivetran/microsoft_ads
version: [">=0.8.0", "<0.9.0"]
version: [">=0.9.0", "<0.10.0"]
```

Do NOT include the `microsoft_ads_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.

### Step 3: Define database and schema variables
By default, this package runs using your destination and the `microsoft_ads` schema. If this is not where your Microsoft Ads data is (for example, if your Microsoft Ads schema is named `microsoft_ads_fivetran`), add the following configuration to your root `dbt_project.yml` file:

Expand All @@ -71,6 +73,8 @@ vars:
```

### (Optional) Step 4: Additional configurations
<details open><summary>Expand/Collapse details</summary>

#### Union multiple connectors
If you have multiple microsoft_ads connectors in Fivetran and would like to use this package on all of them simultaneously, we have provided functionality to do so. The package will union all of the data together and pass the unioned table into the transformations. You will be able to see which source it came from in the `source_relation` column of each model. To use this functionality, you will need to set either the `microsoft_ads_union_schemas` OR `microsoft_ads_union_databases` variables (cannot do both) in your root `dbt_project.yml` file:

Expand All @@ -84,9 +88,9 @@ vars:
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.

#### Adding passthrough 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`, `spend`, `conversions` (coalesces source `conversions` and `conversions_qualified` fields), `conversions_value` (aliased source `revenue` field), `all_conversions` (coalesces source `all_conversions` and `all_conversions_qualified` fields) and `all_conversions_value` (aliased source `all_revenue` field) 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:

> IMPORTANT: Make sure to exercise 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, such as metric averages, which may be inaccurately represented at the grain for reports created in this package. You must ensure that whichever metrics you pass through are appropriate to aggregate at the respective reporting levels in this package.
> IMPORTANT: Make sure to exercise due diligence when adding metrics to these models. The metrics added by default 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.

```yml
vars:
Expand All @@ -98,7 +102,7 @@ vars:
microsoft_ads__ad_group_passthrough_metrics:
- name: "unique_string_field"
alias: "field_id"
microsoft_ads__ad_passthrough_metrics:
microsoft_ads__ad_passthrough_metrics: #these metrics are included in both microsoft_ads__ad_report and microsoft_ads__url_report
- name: "new_custom_field"
alias: "custom_field"
- name: "a_second_field"
Expand All @@ -110,14 +114,15 @@ vars:
```

#### Enable UTM Auto Tagging
This package assumes you are manually adding UTM tags to your ads. If you are leveraging the auto-tag feature within Microsoft Ads then you will want to enable the `google_auto_tagging_enabled` variable to correctly populate the UTM fields within the `microsoft_ads__utm_report` model.
This package assumes you are manually adding UTM tags to your ads. If you are leveraging the auto-tag feature within Microsoft Ads then you will want to enable the `microsoft_ads_auto_tagging_enabled` variable to correctly populate the UTM fields within the `microsoft_ads__utm_report` model.

```yml
vars:
microsoft_ads_auto_tagging_enabled: true # False by default
```

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

```yml
models:
Expand All @@ -137,6 +142,8 @@ vars:
microsoft_ads_<default_source_table_name>_identifier: your_table_name
```

</details>

### (Optional) Step 5: Orchestrate your models with Fivetran Transformations for dbt Core™
<details><summary>Expand for more details</summary>

Expand All @@ -151,7 +158,7 @@ This dbt package is dependent on the following dbt packages. These dependencies
```yml
packages:
- package: fivetran/microsoft_ads_source
version: [">=0.9.0", "<0.10.0"]
version: [">=0.10.0", "<0.11.0"]
- package: fivetran/fivetran_utils
version: [">=0.4.0", "<0.5.0"]
Expand All @@ -174,6 +181,11 @@ A small team of analytics engineers at Fivetran develops these dbt packages. How

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) on the best workflow for contributing to a package.

#### Contributors
We thank [everyone](https://github.com/fivetran/dbt_microsoft_ads/graphs/contributors) who has taken the time to contribute. Each PR, bug report, and feature request has made this package better and is truly appreciated.

A special thank you to [Seer Interactive](https://www.seerinteractive.com/?utm_campaign=Fivetran%20%7C%20Models&utm_source=Fivetran&utm_medium=Fivetran%20Documentation), who we closely collaborated with to introduce native conversion support to our Ad packages.

## Are there any resources available?
- If you have questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_microsoft_ads/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).
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'microsoft_ads'
version: '0.8.0'
version: '0.9.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.

1 change: 0 additions & 1 deletion docs/run_results.json

This file was deleted.

10 changes: 5 additions & 5 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ integration_tests:
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
port: 5439
schema: microsoft_ads_integration_tests_5
schema: microsoft_ads_integration_tests_6
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: microsoft_ads_integration_tests_5
schema: microsoft_ads_integration_tests_6
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
Expand All @@ -33,7 +33,7 @@ integration_tests:
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: microsoft_ads_integration_tests_5
schema: microsoft_ads_integration_tests_6
threads: 8
postgres:
type: postgres
Expand All @@ -42,13 +42,13 @@ integration_tests:
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: microsoft_ads_integration_tests_5
schema: microsoft_ads_integration_tests_6
threads: 8
databricks:
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: microsoft_ads_integration_tests_5
schema: microsoft_ads_integration_tests_6
threads: 8
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
18 changes: 13 additions & 5 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'microsoft_ads_integration_tests'
version: '0.8.0'
version: '0.9.0'
profile: 'integration_tests'
config-version: 2

vars:
microsoft_ads_schema: microsoft_ads_integration_tests_5
microsoft_ads_schema: microsoft_ads_integration_tests_6
microsoft_ads_account_history_identifier: "microsoft_ads_account_history_data"
microsoft_ads_account_performance_daily_report_identifier: "microsoft_ads_account_performance_daily_report_data"
microsoft_ads_ad_group_history_identifier: "microsoft_ads_ad_group_history_data"
Expand All @@ -17,8 +17,8 @@ vars:
microsoft_ads_keyword_performance_daily_report_identifier: "microsoft_ads_keyword_performance_daily_report_data"
microsoft_ads_search_query_performance_daily_report_identifier: "microsoft_ads_search_performance_daily_report_data"

models:
+schema: "microsoft_ads_{{ var('directed_schema','dev') }}"
# models:
# +schema: "microsoft_ads_{{ var('directed_schema','dev') }}"

seeds:
microsoft_ads_integration_tests:
Expand All @@ -31,7 +31,15 @@ seeds:
keyword_id: "{{ 'INT64' if target.type == 'bigquery' else 'bigint' }}"
last_modified_time: "timestamp"
modified_time: "timestamp"
spend: "float"
spend: "numeric"
impressions: "integer"
clicks: "integer"
conversions_qualified: "integer"
conversions: "integer"
revenue: "numeric"
all_conversions_qualified: "integer"
all_conversions: "integer"
all_revenue: "numeric"

dispatch:
- macro_namespace: dbt_utils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
date,account_id,device_os,device_type,network,currency_code,ad_distribution,bid_match_type,delivered_match_type,top_vs_other,clicks,impressions,spend
2019-04-25,150175881,Android,Smartphone,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0
2019-03-15,150175881,Unknown,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0
2019-05-11,150175881,Windows,Computer,AOL search,USD,Search,Phrase,Phrase,AOL search - Top,0,0,0.0
2019-04-21,150175881,Android,Smartphone,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0
2019-04-15,150175881,iOS,Tablet,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0
2019-04-22,150175881,Unknown,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0
2018-12-06,150175881,Unknown,Computer,AOL search,USD,Search,Phrase,Phrase,AOL search - Top,0,0,0.0
2019-04-15,150175881,Windows,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0
2019-04-16,150175881,Unknown,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0
2018-12-26,150175881,Windows,Computer,AOL search,USD,Search,Broad,Phrase,AOL search - Top,0,0,0.0
date,account_id,device_os,device_type,network,currency_code,ad_distribution,bid_match_type,delivered_match_type,top_vs_other,clicks,impressions,spend,conversions_qualified,conversions,revenue,all_conversions_qualified
2019-04-25,150175881,Android,Smartphone,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0,0,0,0.0,0
2019-03-15,150175881,Unknown,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0,,,,
2019-05-11,150175881,Windows,Computer,AOL search,USD,Search,Phrase,Phrase,AOL search - Top,0,0,0.0,0,0,0.0,0
2019-04-21,150175881,Android,Smartphone,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0,0,0,0.0,0
2019-04-15,150175881,iOS,Tablet,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0,0,0,0.0,0
2019-04-22,150175881,Unknown,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0,0,0,0.0,0
2018-12-06,150175881,Unknown,Computer,AOL search,USD,Search,Phrase,Phrase,AOL search - Top,0,0,0.0,0,0,0.0,0
2019-04-15,150175881,Windows,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0,0,0,0.0,0
2019-04-16,150175881,Unknown,Computer,AOL search,USD,Search,Broad,Broad,AOL search - Top,0,0,0.0,0,0,0.0,0
2018-12-26,150175881,Windows,Computer,AOL search,USD,Search,Broad,Phrase,AOL search - Top,4,5,0.0,1,2,0.1,3
Loading

0 comments on commit e64e8a9

Please sign in to comment.