Skip to content

Commit afd4974

Browse files
Add conversion metrics (#26)
* things are running * working and tests passing * docs * polishes * joe feedback * adjust field names to be consistent * source package ref - buildkite will fail * document 2 vars
1 parent eba6f86 commit afd4974

26 files changed

Lines changed: 774 additions & 42 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dbt_modules/
44
logs/
55
.DS_Store
66
integration_tests/.DS_Store
7-
dbt_packages/
7+
dbt_packages/
8+
integration_tests/package-lock.yml

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# dbt_twitter v0.8.0
2+
3+
[PR #26](https://github.com/fivetran/dbt_twitter/pull/26) includes the following **BREAKING CHANGE** updates:
4+
5+
## Feature Updates: Native Conversion Support
6+
We have added more robust support for conversions in our data models by doing the following:
7+
- Created the `twitter_ads__conversion_fields` and `twitter_ads__conversion_sale_amount_fields` variables to pass through conversion metrics (total number and monetary value, respectively). Conversion metrics are split into these 2 variables due to the N:1 relationship between Twitter conversions and their conversion value fields.
8+
- By default, `twitter_ads__conversion_fields` will include `conversion_purchases_metric` and `conversion_custom_metric`.
9+
- By default, `twitter_ads__conversion_sale_amount_fields` will include `conversion_purchases_sale_amount` and `conversion_custom_sale_amount`.
10+
- These conversion fields will be included in each end model report. Additionally, they will be summed up into new `total_conversions` and `total_conversions_sale_amount` columns.
11+
- See [README](https://github.com/fivetran/dbt_twitter?tab=readme-ov-file#customizing-types-of-conversions) for more details on how to configure these variables.
12+
13+
## Under the Hood
14+
- Ensured the above changes maintain backwards compatibility with [existing passthrough column variables](https://github.com/fivetran/dbt_twitter?tab=readme-ov-file#passing-through-additional-metrics).
15+
- Added a new [version](https://github.com/fivetran/dbt_twitter_ads/blob/main/macros/twitter_ads_persist_pass_through_columns.sql) of the `persist_pass_through_columns()` [macro](https://github.com/fivetran/dbt_fivetran_utils/blob/v0.4.10/macros/persist_pass_through_columns.sql) in which we can include coalesces and properly check between conversion field values and the existing passthrough columns.
16+
- Added integrity and consistency validation tests within `integration_tests` for the Twitter Ads transformation models.
17+
18+
## Documentation
19+
- Highlighted all metrics included in the package by default. Previously, `url_clicks` and `spend_micro` were missing from this README [section](https://github.com/fivetran/dbt_twitter?tab=readme-ov-file#passing-through-additional-metrics).
20+
- Documented how to configure the new `twitter_ads__conversion_fields` and `twitter_ads__conversion_sale_amount_fields` variables [here](https://github.com/fivetran/dbt_twitter?tab=readme-ov-file#customizing-types-of-conversions).
21+
- Added Contributors [subsection](https://github.com/fivetran/dbt_twitter?tab=readme-ov-file#contributors) to README.
22+
23+
## Contributors
24+
- [Seer Interactive](https://www.seerinteractive.com/?utm_campaign=Fivetran%20%7C%20Models&utm_source=Fivetran&utm_medium=Fivetran%20Documentation)
25+
126
# dbt_twitter v0.7.0
227
[PR #21](https://github.com/fivetran/dbt_twitter/pull/21) includes the following updates:
328
## Feature update 🎉

README.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ dispatch:
4848
search_order: ['spark_utils', 'dbt_utils']
4949
```
5050
51-
### Step 2: Install the package
52-
Include the following Twitter package version in your `packages.yml` file:
51+
### Step 2: Install the package (skip if using `ad_reporting` combination package)
52+
If you are not using the downstream [Ad Reporting](https://github.com/fivetran/dbt_ad_reporting) combination package, include the following Twitter package version in your `packages.yml` file:
5353
> 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
5454

5555
```yml
5656
# packages.yml
5757
packages:
5858
- package: fivetran/twitter_ads
59-
version: [">=0.7.0", "<0.8.0"] # we recommend using ranges to capture non-breaking changes automatically
59+
version: [">=0.8.0", "<0.9.0"] # we recommend using ranges to capture non-breaking changes automatically
6060
```
6161
Do NOT include the `twitter_ads_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.
6262

@@ -79,6 +79,8 @@ vars:
7979
```
8080

8181
### (Optional) Step 5: Additional configurations
82+
<details open><summary>Expand/Collapse details</summary>
83+
8284
#### Union multiple connectors
8385
If you have multiple twitter 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 `twitter_ads_union_schemas` OR `twitter_ads_union_databases` variables (cannot do both) in your root `dbt_project.yml` file:
8486

@@ -91,8 +93,39 @@ vars:
9193

9294
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.
9395

96+
#### Customizing Types of Conversions
97+
The package will include conversion metrics provided to the following variables in each model.
98+
99+
| Variable | Definition | Default Values |
100+
| -------- | -------- | -------- |
101+
| `twitter_ads__conversion_fields` | Which fields should be included in calculating total number of conversions. | `conversion_purchases_metric`, `conversion_custom_metric` |
102+
| `twitter_ads__conversion_sale_amount_fields` | Which `*_sale_amount` fields should be included in calculating the total value of conversions. | `conversion_purchases_sale_amount`, `conversion_custom_sale_amount` |
103+
104+
In addition, the fields included in `var('twitter_ads__conversion_fields')` will be summed up into a `total_conversions` field, and the fields included in `var('twitter_ads__conversion_sale_amount_fields')` will be summed up into a `total_conversions_sale_amount` field.
105+
106+
By default, the data models include purchases and custom conversion events in both variables. However, you can configure each to include any types of conversions available in the Twitter Ads source `*_report` tables:
107+
108+
```yml
109+
# dbt_project.yml
110+
vars:
111+
twitter_ads__conversion_fields:
112+
- conversion_purchases_metric
113+
- conversion_sign_ups_metric
114+
- mobile_conversion_payment_info_additions_post_engagement
115+
- mobile_conversion_add_to_wishlists_post_engagement
116+
- mobile_conversion_add_to_carts_post_engagement
117+
- mobile_conversion_checkouts_initiated_post_engagement
118+
- <any conversion field you want to include>
119+
twitter_ads__conversion_sale_amount_fields:
120+
- conversion_purchases_sale_amount
121+
- conversion_sign_ups_sale_amount
122+
- <any conversion value/sale amount field you want to include>
123+
```
124+
125+
> We recommend using the same *types* of conversion events for `twitter_ads__conversion_fields` and `twitter_ads__conversion_sale_amount_fields` so that `total_conversions` and `total_conversions_sale_amount` properly map onto each other, but this is not required. We chose to split conversions and conversion values into 2 distinct variables due to the N:1 relationship beteen conversions and conversion value fields.
126+
94127
#### Passing Through Additional Metrics
95-
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:
128+
Besides the above conversion fields, this package by default will select `clicks`, `url_clicks`, `impressions`, `spend` (calculated from `billed_charge_local_micro`), and `spend_micro` (aliased from `billed_charge_local_micro`) 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:
96129

97130
> 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.
98131

@@ -132,6 +165,8 @@ vars:
132165
twitter_ads_<default_source_table_name>_identifier: your_table_name
133166
```
134167

168+
</details>
169+
135170
### (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™
136171
<details><summary>Expand for more details</summary>
137172
<br>
@@ -146,8 +181,8 @@ This dbt package is dependent on the following dbt packages. These dependencies
146181

147182
```yml
148183
packages:
149-
- package: fivetran/twitter_source
150-
version: [">=0.7.0", "<0.8.0"]
184+
- package: fivetran/twitter_ads_source
185+
version: [">=0.8.0", "<0.9.0"]
151186
- package: fivetran/fivetran_utils
152187
version: [">=0.4.0", "<0.5.0"]
153188
- package: dbt-labs/dbt_utils
@@ -166,6 +201,13 @@ In creating this package, which is meant for a wide range of use cases, we had t
166201
### Contributions
167202
A small team of analytics engineers at Fivetran develops these dbt packages. However, the packages are made better by community contributions.
168203

204+
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.
205+
206+
#### Contributors
207+
We thank [everyone](https://github.com/fivetran/dbt_twitter/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.
208+
209+
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.
210+
169211
## Are there any resources available?
170212
- If you have questions or want to reach out for help, see the [GitHub Issue](https://github.com/fivetran/dbt_twitter/issues/new/choose) section to find the right avenue of support for you.
171213
- 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).

dbt_project.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'twitter_ads'
2-
version: '0.7.0'
2+
version: '0.8.0'
33
config-version: 2
44
require-dbt-version: [">=1.3.0", "<2.0.0"]
55
models:
@@ -22,3 +22,10 @@ vars:
2222
twitter_ads__line_item_report_passthrough_metrics: []
2323
twitter_ads__line_item_keywords_report_passthrough_metrics: []
2424
twitter_ads__promoted_tweet_report_passthrough_metrics: []
25+
26+
twitter_ads__conversion_fields:
27+
- conversion_purchases_metric
28+
- conversion_custom_metric
29+
twitter_ads__conversion_sale_amount_fields:
30+
- conversion_purchases_sale_amount
31+
- conversion_custom_sale_amount

docs/catalog.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/index.html

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

docs/manifest.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/run_results.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

integration_tests/dbt_project.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
name: 'twitter_integration_tests'
2-
version: '0.7.0'
2+
version: '0.8.0'
33
profile: 'integration_tests'
44
config-version: 2
55
snapshot-paths: ["snapshots"]
66

7+
models:
8+
+schema: "twitter_ads_{{ var('directed_schema','dev') }}"
9+
710
vars:
11+
twitter_ads__line_item_report_passthrough_metrics:
12+
- name: "conversion_purchases_metric"
13+
- name: "conversion_custom_sale_amount"
14+
alias: "custom_conversion_value"
15+
16+
twitter_ads__conversion_sale_amount_fields:
17+
- conversion_purchases_sale_amount
18+
- conversion_custom_sale_amount
19+
- conversion_sign_ups_sale_amount
20+
821
twitter_ads_source:
922
twitter_ads_schema: twitter_ads_integration_tests_4
1023

integration_tests/packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
packages:
2-
- local: ../
2+
- local: ../

0 commit comments

Comments
 (0)