Skip to content
Draft
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# dbt_google_ads_source v0.10.0

## 🚨 Breaking Changes 🚨
- Added `final_url_suffix` into the `stg_google_ads__ad_history` model in order to gather all the UTM information. With this, the package now provides preference to the `final_url_suffix` field as opposed to the `final_urls` when constructing the `final_url` field in the staging model. Be sure to pay attention as this could change the output of your Google Ads data from the previous build of the package. This was done to be more in line with Google's guidelines on defining UTM parameters for ads.

## 🎉 Feature Enhancements 🎉
- Updated macros, `get_ad_history_columns` and `get_campaign_history_columns`, to include `final_url_suffix` as a new column.
- Added `final_url_suffix` into the `stg_google_ads__campaign_history` model in order to gather all the UTM information for each campaign and because the UTMs can only be configured in this field when the campaign is set up.

## Contributors
- [@jocelyn-metricbox](https://github.com/jocelyn-metricbox)

# dbt_google_ads_source v0.9.2
## 🐛 Bug fix
- Updated configuration to allow the source database to be set as `target.database` when using Databricks. ([#38](https://github.com/fivetran/dbt_google_ads_source/pull/38))
Expand All @@ -9,6 +21,7 @@
# dbt_google_ads_source v0.9.1
## Under the Hood Updates
- The dbt-expectations [regex_inst macro received an update](https://github.com/calogica/dbt-expectations/pull/247) that included a new `flags` argument. This argument is not included in the replica macro located within this package. As such, the update needs to be reflected in order to allow the downstream references of the macro to succeed. ([#35](https://github.com/fivetran/dbt_google_ads_source/pull/35))

# dbt_google_ads_source v0.9.0

## 🚨 Breaking Changes 🚨:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ If you are **not** using the [Google Ads transformation package](https://github
```yml
packages:
- package: fivetran/google_ads_source
version: [">=0.9.0", "<0.10.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.10.0", "<0.11.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 Down
3 changes: 2 additions & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'google_ads_source'
version: '0.9.2'
version: '0.9.3'

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.

6 changes: 3 additions & 3 deletions docs/index.html

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.

3 changes: 2 additions & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'google_ads_source_integration_tests'
version: '0.9.2'
version: '0.10.0'

profile: 'integration_tests'
config-version: 2

Expand Down
8 changes: 4 additions & 4 deletions integration_tests/seeds/campaign_history_data.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
id,updated_at,name,customer_id,advertising_channel_type,advertising_channel_subtype,start_date,end_date,serving_status,status,tracking_url_template
9935249409,2021-06-29T17:19:05.102,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2021-08-25T20:21:09.602,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2021-08-25T20:21:09.602,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,"{lpurl}?creative={creative}&keyword={keyword}&matchtype={matchtype}&#demo"
9935249409,2022-05-31T17:55:44.964,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2022-06-21T03:38:52,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2022-06-24T05:35:31,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2022-07-12T06:48:40,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2022-08-01T14:21:25,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2022-08-08T16:16:48,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2022-07-12T06:48:40,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,"{lpurl}?creative={creative}&keyword={keyword}&matchtype={matchtype}&#demo"
9935249409,2022-08-01T14:21:25,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,"{lpurl}?creative={creative}&keyword={keyword}&matchtype={matchtype}&#demo"
9935249409,2022-08-08T16:16:48,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,"{lpurl}?creative={creative}&keyword={keyword}&matchtype={matchtype}&#demo"
9935249409,2022-08-12T08:15:49,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
9935249409,2022-08-17T12:09:49,Zj9yTjsXtiWREoWWkz3kww==,2121450128,SEARCH,UNSPECIFIED,2020-04-22,2037-12-30,SERVING,PAUSED,
1 change: 1 addition & 0 deletions macros/get_ad_history_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{"name": "ad_group_id", "datatype": dbt.type_int()},
{"name": "display_url", "datatype": dbt.type_string()},
{"name": "final_urls", "datatype": dbt.type_string()},
{"name": "final_url_suffix", "datatype": dbt.type_string()},
{"name": "id", "datatype": dbt.type_int()},
{"name": "name", "datatype": dbt.type_string()},
{"name": "status", "datatype": dbt.type_string()},
Expand Down
1 change: 1 addition & 0 deletions macros/get_campaign_history_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{"name": "start_date", "datatype": dbt.type_string()},
{"name": "status", "datatype": dbt.type_string()},
{"name": "tracking_url_template", "datatype": dbt.type_string()},
{"name": "final_url_suffix", "datatype": dbt.type_string()},
{"name": "updated_at", "datatype": dbt.type_timestamp()}
] %}

Expand Down
2 changes: 2 additions & 0 deletions models/src_google_ads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ sources:
description: "{{ doc('ad_status') }}"
- name: final_urls
description: A list of urls that are used for the ad.
- name: final_url_suffix
description: The suffix to use when constructing a final URL.

- name: ad_group_history
description: Each record represents a version of an ad group in Google Ads.
Expand Down
14 changes: 14 additions & 0 deletions models/stg_google_ads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ models:
description: "{{ doc('ad_id') }}"
tests:
- not_null
- name: ad_name
description: The name of the ad.
- name: updated_at
description: "{{ doc('updated_at') }}"
- name: display_url
Expand All @@ -78,6 +80,10 @@ models:
description: "{{ doc('ad_status') }}"
- name: is_most_recent_record
description: "{{ doc('is_most_recent_record') }}"
- name: final_urls
description: A list of urls that are used for the ad.
- name: final_url_suffix
description: The suffix to use when constructing a final URL.
- name: source_final_urls
description: The original list of final urls expressed as an array. Please be aware the test used on this field is intended to warn you if you have fields with multiple urls. If you do, the `final_url` field will filter down the urls within the array to just the first. Therefore, this package will only leverage one of possibly many urls within this field array.
tests:
Expand Down Expand Up @@ -171,10 +177,18 @@ models:
description: General status of the campaign.
- name: tracking_url_template
description: The tracking url template being used throughout the campaign ads.
- name: final_url_suffix
description: Suffix used to append query parameters to landing pages that are served with parallel tracking.
- name: campaign_name
description: "{{ doc('campaign_name') }}"
- name: account_id
description: "{{ doc('external_customer_id') }}"
- name: utm_source
description: "{{ doc('utm_source') }}"
- name: utm_medium
description: "{{ doc('utm_medium') }}"
- name: utm_campaign
description: "{{ doc('utm_campaign') }}"
- name: is_most_recent_record
description: "{{ doc('is_most_recent_record') }}"

Expand Down
20 changes: 14 additions & 6 deletions models/stg_google_ads__ad_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ final as (
type as ad_type,
status as ad_status,
display_url,
final_urls as source_final_urls,
final_urls as source_final_urls,
replace(replace(final_urls, '[', ''),']','') as final_urls,
--Adding final_url_suffix because sometimes the UTMs are only configured in the final_url_suffix rather than the final_urls
nullif(final_url_suffix, '') as final_url_suffix,
row_number() over (partition by id, ad_group_id order by updated_at desc) = 1 as is_most_recent_record
from fields
),
Expand All @@ -52,11 +54,17 @@ url_fields as (
{{ dbt.split_part('final_url', "'?'", 1) }} as base_url,
{{ dbt_utils.get_url_host('final_url') }} as url_host,
'/' || {{ dbt_utils.get_url_path('final_url') }} as url_path,
{{ dbt_utils.get_url_parameter('final_url', 'utm_source') }} as utm_source,
{{ dbt_utils.get_url_parameter('final_url', 'utm_medium') }} as utm_medium,
{{ dbt_utils.get_url_parameter('final_url', 'utm_campaign') }} as utm_campaign,
{{ dbt_utils.get_url_parameter('final_url', 'utm_content') }} as utm_content,
{{ dbt_utils.get_url_parameter('final_url', 'utm_term') }} as utm_term
--Extracting UTMs for url report's use
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_source') }} ,
{{ dbt_utils.get_url_parameter('final_url', 'utm_source') }} ) as utm_source,
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_medium') }} ,
{{ dbt_utils.get_url_parameter('final_url', 'utm_medium') }} ) as utm_medium,
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_campaign') }} ,
{{ dbt_utils.get_url_parameter('final_url', 'utm_campaign') }} ) as utm_campaign,
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_content') }} ,
{{ dbt_utils.get_url_parameter('final_url', 'utm_content') }} ) as utm_content,
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_term') }} ,
{{ dbt_utils.get_url_parameter('final_url', 'utm_term') }} ) as utm_term
from final_urls
)

Expand Down
9 changes: 9 additions & 0 deletions models/stg_google_ads__campaign_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ final as (
serving_status,
status,
tracking_url_template,
--Adding final_url_suffix because sometimes the UTMs are only configured in the final_url_suffix than the tracking template
final_url_suffix,
--Extracting UTMs for campaign report's use
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_source') }} ,
{{ dbt_utils.get_url_parameter('tracking_url_template', 'utm_source') }} ) as utm_source,
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_medium') }} ,
{{ dbt_utils.get_url_parameter('tracking_url_template', 'utm_medium') }} ) as utm_medium,
coalesce( {{ dbt_utils.get_url_parameter('final_url_suffix', 'utm_campaign') }} ,
{{ dbt_utils.get_url_parameter('tracking_url_template', 'utm_campaign') }} ) as utm_campaign,
row_number() over (partition by id order by updated_at desc) = 1 as is_most_recent_record
from fields
)
Expand Down