Skip to content

Commit

Permalink
remove commented out code and polish things
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-jamie committed Nov 5, 2024
1 parent 5850ac6 commit e5b74f3
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 65 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ vars:
- name: "_7_d_click"
alias: "conversion_value_7d_click"
- name: "_1_d_view"
facebook_ads__basic_ad_action_values_passthrough_metrics: # add conversion metrics found in BASIC_AD_ACTIONS
facebook_ads__basic_ad_action_values_passthrough_metrics: # add conversion metrics found in BASIC_AD_ACTION_VALUES
- name: "_7_d_click"
alias: "conversion_value_7d_click"
- name: "_1_d_view"
Expand All @@ -135,13 +135,13 @@ However, you may choose your own `action_types` to consider as conversions. To d
# dbt_project.yml
vars:
facebook_ads__conversion_action_types: # case-insensitive
- name: exact_conversion_action_type_name # will grab `basic_ad_actions` records where action_type = 'exact_conversion_action_type_name'
- name: exact_conversion_action_type_name # will grab `basic_ad_actions` and `basic_ad_action_values` records where action_type = 'exact_conversion_action_type_name'
- pattern: onsite_conversion% # will grab all `onsite_conversion%` records
- name: offsite_conversion.custom.my_custom_conversion_123
- name: very_specific_conversion_action
where_sql: source_relation = 'specific advertiser source' # will grab `basic_ad_actions` records where (action_type = very_specific_conversion_action and {{ where_sql }})
where_sql: source_relation = 'specific advertiser source' # will grab `basic_ad_actions` and `basic_ad_action_values` records where (action_type = very_specific_conversion_action and {{ where_sql }})
- pattern: subscribe%
where_sql: source_relation = 'advertiser who only cares about subscriptions' # will grab `basic_ad_actions` records where (action_type like 'subscribe%' and {{ where_sql }})
where_sql: source_relation = 'advertiser who only cares about subscriptions' # will grab `basic_ad_actions` and `basic_ad_action_values` records where (action_type like 'subscribe%' and {{ where_sql }})
```
> **Note**: Please ensure to exercise due diligence when adding or removing conversion action types. The action types added by default have been heavily vetted by our friends at [Seer Interactive](https://www.seerinteractive.com/) and the Fivetran team maintaining this package for accuracy. There are many ways to accidentally double-count conversion values, as some action types are hierarchical/aggregates or overlap with others. Reference the action type descriptions in the Meta [API docs](https://developers.facebook.com/docs/marketing-api/reference/ads-action-stats/) to ensure you select action types that appropriately and accurately fit your use case.
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.

6 changes: 0 additions & 6 deletions models/facebook_ads__account_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ joined as (
sum(coalesce(conversion_report.conversions, 0)) as conversions,
sum(coalesce(conversion_report.conversions_value, 0)) as conversions_value

{# {% for action_type in var('facebook_ads__conversion_action_types') -%}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}_value
{%- endfor -%} #}

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_passthrough_metrics', transform = 'sum') }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_actions_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_action_values_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
Expand Down
6 changes: 0 additions & 6 deletions models/facebook_ads__ad_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ joined as (
sum(coalesce(conversion_report.conversions, 0)) as conversions,
sum(coalesce(conversion_report.conversions_value, 0)) as conversions_value

{# {% for action_type in var('facebook_ads__conversion_action_types') -%}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}_value
{%- endfor -%} #}

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_passthrough_metrics', transform = 'sum') }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_actions_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_action_values_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
Expand Down
6 changes: 0 additions & 6 deletions models/facebook_ads__ad_set_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ joined as (
sum(coalesce(conversion_report.conversions, 0)) as conversions,
sum(coalesce(conversion_report.conversions_value, 0)) as conversions_value

{# {% for action_type in var('facebook_ads__conversion_action_types') -%}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}_value
{%- endfor -%} #}

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_passthrough_metrics', transform = 'sum') }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_actions_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_action_values_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
Expand Down
6 changes: 0 additions & 6 deletions models/facebook_ads__campaign_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ joined as (
sum(coalesce(conversion_report.conversions, 0)) as conversions,
sum(coalesce(conversion_report.conversions_value, 0)) as conversions_value

{# {% for action_type in var('facebook_ads__conversion_action_types') -%}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}_value
{%- endfor -%} #}

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_passthrough_metrics', transform = 'sum') }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_actions_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_action_values_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
Expand Down
6 changes: 0 additions & 6 deletions models/facebook_ads__url_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ joined as (
sum(coalesce(conversion_report.conversions, 0)) as conversions,
sum(coalesce(conversion_report.conversions_value, 0)) as conversions_value

{# {% for action_type in var('facebook_ads__conversion_action_types') -%}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}
, sum(conversion_report.{{ dbt_utils.slugify(action_column) }}) as {{ dbt_utils.slugify(action_column) }}_value
{%- endfor -%} #}

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_passthrough_metrics', transform = 'sum') }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_actions_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
{{ facebook_ads_persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_action_values_passthrough_metrics', transform = 'sum', coalesce_with=0) }}
Expand Down
30 changes: 1 addition & 29 deletions models/intermediate/int_facebook_ads__conversions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ action_metrics as (
ad_id,
date_day,
sum(conversions) as conversions

{# Iterate over each action_type to split it into a distinct column for deep dives #}
{# {% for action_type in var('facebook_ads__conversion_action_types') %}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}

, sum(case when
{%- if action_type.where_sql %} {{ action_type.where_sql }} and {% endif %}
action_type {{ '=' if action_type.name else 'like' }} '{{ action_column }}' then conversions else 0 end) as {{ dbt_utils.slugify(action_column) }}

{%- endfor -%} #}

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_actions_passthrough_metrics', transform='sum') }}

Expand Down Expand Up @@ -61,16 +51,6 @@ action_value_metrics as (
date_day,
sum(conversions_value) as conversions_value

{# Iterate over each action_type to split it into a distinct column for deep dives #}
{# {% for action_type in var('facebook_ads__conversion_action_types') %}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}

, sum(case when
{%- if action_type.where_sql %} {{ action_type.where_sql }} and {% endif %}
action_type {{ '=' if action_type.name else 'like' }} '{{ action_column }}' then conversions_value else 0 end) as {{ dbt_utils.slugify(action_column) }}_value

{%- endfor -%} #}

{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_action_values_passthrough_metrics', transform='sum') }}

from action_values_report
Expand Down Expand Up @@ -103,15 +83,7 @@ metrics_join as (
action_metrics.date_day,
action_metrics.conversions,
action_value_metrics.conversions_value

{# {% for action_type in var('facebook_ads__conversion_action_types') -%}
{%- set action_column = action_type.name|default(action_type.pattern)|replace(".", "_") %}

, action_metrics.{{ dbt_utils.slugify(action_column) }}
, action_value_metrics.{{ dbt_utils.slugify(action_column) }}_value

{%- endfor -%} #}


{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_actions_passthrough_metrics', identifier='action_metrics') }}
{{ fivetran_utils.persist_pass_through_columns(pass_through_variable='facebook_ads__basic_ad_action_values_passthrough_metrics', identifier='action_value_metrics') }}

Expand Down

0 comments on commit e5b74f3

Please sign in to comment.