diff --git a/.gitignore b/.gitignore index ca03098..232daa6 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,10 @@ __pycache__ None.yml *.log .cursorignore -.vscode/ + +#PyCharm +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf diff --git a/dbt_project.yml b/dbt_project.yml index 7b7edaf..f9ba53e 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -199,9 +199,9 @@ models: google_analytics: staging: +schema: support + +materialized: view intermediate: +schema: support - +materialized: ephemeral customer_io: staging: diff --git a/macros/get_prefixed_columns.sql b/macros/get_prefixed_columns.sql new file mode 100644 index 0000000..a738d6d --- /dev/null +++ b/macros/get_prefixed_columns.sql @@ -0,0 +1,20 @@ +{% macro get_prefixed_columns(relation_ref, prefix, exclude=[]) %} + + {%- set column_names = dbt_utils.get_filtered_columns_in_relation( + from=relation_ref, + except=['shop_subdomain', 'user_pseudo_id'] + exclude + ) + -%} + + {%- for column_name in column_names -%} + {%- if column_name|lower == 'event_timestamp_pt' or column_name|lower == 'created_at' -%} + {{ column_name }} AS {{ prefix }}_at_pt + {%- else -%} + iff( + {{ column_name }}::varchar = '', null, {{ column_name }} + ) AS {{ prefix }}_{{ column_name|lower }} + {%- endif -%} + {%- if not loop.last %},{% endif %} + {% endfor -%} + +{% endmacro %} diff --git a/macros/should_exclude_column_by_prefix.sql b/macros/should_exclude_column_by_prefix.sql new file mode 100644 index 0000000..acaa32a --- /dev/null +++ b/macros/should_exclude_column_by_prefix.sql @@ -0,0 +1,9 @@ +{% macro should_exclude_column_by_prefix(column_name, excluded_prefixes, result) %} + {% for prefix in excluded_prefixes %} + {% if column_name.startswith(prefix) %} + {# {{ log('Debug: excluding column ' ~ column_name ~ ' because it starts with ' ~ prefix, info=True) }} #} + {% set _ = result.append(true) %} + {% break %} + {% endif %} + {% endfor %} +{% endmacro %} diff --git a/models/google_analytics/intermediate/_int_app_store_attribution_schema.yml b/models/google_analytics/intermediate/_int_app_store_attribution_schema.yml new file mode 100644 index 0000000..9854aee --- /dev/null +++ b/models/google_analytics/intermediate/_int_app_store_attribution_schema.yml @@ -0,0 +1,12 @@ +version: 2 +models: + - name: int_app_store_attribution + tests: + - dbt_expectations.expect_table_row_count_to_be_between: + min_value: 200 + columns: + - name: shop_subdomain + tests: + - unique + - not_null + description: The foreign key for the Shop. diff --git a/models/google_analytics/staging/_stg_ga_first_visits_schema.yml b/models/google_analytics/intermediate/_int_ga_first_visits_schema.yml similarity index 63% rename from models/google_analytics/staging/_stg_ga_first_visits_schema.yml rename to models/google_analytics/intermediate/_int_ga_first_visits_schema.yml index 61c05cf..b1a07ca 100644 --- a/models/google_analytics/staging/_stg_ga_first_visits_schema.yml +++ b/models/google_analytics/intermediate/_int_ga_first_visits_schema.yml @@ -1,6 +1,6 @@ version: 2 models: - - name: stg_ga_first_visits + - name: int_ga_first_visits tests: - dbt_expectations.expect_table_row_count_to_be_between: min_value: 100 @@ -9,36 +9,36 @@ models: - name: user_pseudo_id decription: the anonymous google analytics id description: the anonymouse google analytics user id - - name: first_touch_at_pt + - name: ga_first_touch_at_pt description: The timestamp of the first touch. - - name: first_touch_url + - name: ga_first_touch_url description: The URL of the first touch. - - name: first_touch_host + - name: ga_first_touch_host description: The host of the first touch. - - name: first_touch_path + - name: ga_first_touch_path description: The path of the first touch. - - name: first_touch_content + - name: ga_first_touch_content description: The content that the shop was acquired through. - - name: first_touch_campaign + - name: ga_first_touch_traffic_source_name description: The campaign that the shop was acquired through. - - name: first_touch_medium + - name: ga_first_touch_traffic_source_medium description: The medium that the shop was acquired through. - - name: first_touch_source + - name: ga_first_touch_traffic_source_source description: The source that the shop was acquired through. - - name: first_touch_referrer_host + - name: ga_first_touch_referrer_host description: The referrer host that referrered the shop's first visit. - - name: first_touch_app_store_surface_detail + - name: ga_first_touch_app_store_surface_detail description: "" - - name: first_touch_app_store_surface_type + - name: ga_first_touch_app_store_surface_type description: The type of surface for the first touch in the app store. - - name: first_touch_app_store_surface_intra_position + - name: ga_first_touch_app_store_surface_intra_position description: The intra position of the first touch on the app store surface. - - name: first_touch_app_store_surface_inter_position + - name: ga_first_touch_app_store_surface_inter_position description: The inter position of the first touch on the app store surface. - - name: first_touch_app_store_locale + - name: ga_first_touch_app_store_locale description: The locale of the first touch in the app store. - name: shop_subdomain - description: The foreign key of the Shop. + description: The foreign key for the Shop. tests: - not_null - unique diff --git a/models/google_analytics/staging/_stg_ga_install_events_schema.yml b/models/google_analytics/intermediate/_int_ga_install_events_schema.yml similarity index 80% rename from models/google_analytics/staging/_stg_ga_install_events_schema.yml rename to models/google_analytics/intermediate/_int_ga_install_events_schema.yml index 699254c..0ba03f5 100644 --- a/models/google_analytics/staging/_stg_ga_install_events_schema.yml +++ b/models/google_analytics/intermediate/_int_ga_install_events_schema.yml @@ -1,12 +1,8 @@ version: 2 models: - - name: stg_ga_install_events + - name: int_ga_install_events description: "" columns: - - name: USER_PSEUDO_ID - description: The anonymouse Google Analytics user ID - tests: - - not_null - name: SHOP_SUBDOMAIN description: The foreign key of the Shop. - name: EVENT_TIMESTAMP diff --git a/models/google_analytics/intermediate/int_app_store_attribution.sql b/models/google_analytics/intermediate/int_app_store_attribution.sql new file mode 100644 index 0000000..bccf951 --- /dev/null +++ b/models/google_analytics/intermediate/int_app_store_attribution.sql @@ -0,0 +1,123 @@ +WITH +shops AS ( + SELECT + shop_subdomain, + first_installed_at_pt + FROM {{ ref('stg_shops') }} +), + +app_store_install_events as ( + select + shop_subdomain, + {{ get_prefixed_columns(ref("int_ga_app_store_page_events"), 'app_store_install', exclude=['event_name']) }} + from {{ ref("int_ga_app_store_page_events") }} + where event_name = 'shopify_app_install' + qualify + row_number() over ( + partition by shop_subdomain order by event_timestamp_pt asc + ) + = 1 +), + +app_store_add_app_button_events as ( + select + shop_subdomain, + {{ get_prefixed_columns(ref("int_ga_app_store_page_events"), 'app_store_add_app', exclude=['event_name']) }} + from {{ ref("int_ga_app_store_page_events") }} + where event_name = 'Add App button' + qualify + row_number() over ( + partition by shop_subdomain order by event_timestamp_pt asc + ) + = 1 +), + +combined_app_store_install_events AS ( + {%- set column_names = dbt_utils.get_filtered_columns_in_relation( + from=ref('int_ga4_events'), + except=['event_timestamp_pt', 'shop_subdomain', 'user_pseudo_id', 'event_name'] + ) + %} + SELECT + shop_subdomain, + {%- for column_name in column_names %} + COALESCE(app_store_install_{{ column_name }}, app_store_add_app_{{ column_name }}) as app_store_install_{{ column_name }} + {%- if not loop.last %},{% endif %} + {%- endfor %}, + COALESCE(app_store_install_at_pt, app_store_add_app_at_pt) as app_store_install_at_pt + FROM app_store_add_app_button_events + INNER JOIN app_store_install_events USING (shop_subdomain) +), + +app_store_ad_clicks as ( + select + shop_subdomain, + {{ get_prefixed_columns(ref("int_ga_app_store_page_events"), 'app_store_ad_click', exclude=['event_name']) }} + from {{ ref("int_ga_app_store_page_events") }} + where page_location ilike '%search_ad%' or event_name = 'shopify_ad_click' + qualify + row_number() over ( + partition by shop_subdomain order by event_timestamp_pt asc + ) + = 1 +), + +app_store_ad_click_counts as ( + select + shop_subdomain, + count_if( + app_store_ad_click_at_pt + <= first_installed_at_pt + interval '60min' + ) + > 0 as app_store_did_click_ad_before_install, + count(app_store_ad_clicks.app_store_ad_click_page_location) + > 0 as app_store_did_click_ad + from shops + left join app_store_ad_clicks using (shop_subdomain) + group by 1 +), + +app_store_organic_clicks as ( + select + shop_subdomain, + {{ get_prefixed_columns(ref("int_ga_app_store_page_events"), 'app_store_organic_click', exclude=['event_name']) }} + from {{ ref("int_ga_app_store_page_events") }} + where + page_location ilike '%surface_type=%' + and page_location not ilike '%search_ad%' + and event_name = 'session_start' + qualify + row_number() over ( + partition by shop_subdomain order by event_timestamp_pt asc + ) + = 1 +), + +final AS ( + SELECT * EXCLUDE (first_installed_at_pt), + coalesce( + app_store_ad_click_app_store_surface_type is not NULL, FALSE + ) as app_store_has_ad_click, + coalesce( + app_store_organic_click_app_store_surface_type is not NULL, FALSE + ) as has_app_store_organic_click, + + case + when + app_store_has_ad_click = TRUE and has_app_store_organic_click = TRUE + then 'app_store_ad_click_and_organic_click' + when app_store_has_ad_click = TRUE + then 'app_store_ad_click' + when has_app_store_organic_click = TRUE + then 'app_store_organic_click' + else '(direct or predates tracking)' + end as app_store_click_type + FROM shops + LEFT JOIN combined_app_store_install_events USING (shop_subdomain) + LEFT JOIN app_store_ad_clicks USING (shop_subdomain) + LEFT JOIN app_store_organic_clicks USING (shop_subdomain) + LEFT JOIN app_store_ad_click_counts USING (shop_subdomain) +) + +SELECT * +FROM final diff --git a/models/google_analytics/intermediate/int_ga4_events.sql b/models/google_analytics/intermediate/int_ga4_events.sql new file mode 100644 index 0000000..b3415cd --- /dev/null +++ b/models/google_analytics/intermediate/int_ga4_events.sql @@ -0,0 +1,27 @@ +WITH +user_matching AS (SELECT * FROM {{ ref("stg_anonymous_to_known_user_matching") }}), + +staged_ga4_events AS ( + SELECT * + FROM {{ ref("stg_ga4_events") }} +), + +final AS ( + + SELECT + user_matching.shop_subdomain, + staged_ga4_events.* + EXCLUDE (shopify_id, shop_subdomain) + + FROM staged_ga4_events + LEFT JOIN user_matching + WHERE + staged_ga4_events.user_pseudo_id = user_matching.user_pseudo_id + OR + staged_ga4_events.shopify_id::STRING = user_matching.shopify_id::STRING + OR + staged_ga4_events.shop_subdomain = user_matching.shop_subdomain +) + +SELECT * +FROM final diff --git a/models/google_analytics/intermediate/int_ga_app_store_page_events.sql b/models/google_analytics/intermediate/int_ga_app_store_page_events.sql new file mode 100644 index 0000000..3842190 --- /dev/null +++ b/models/google_analytics/intermediate/int_ga_app_store_page_events.sql @@ -0,0 +1,14 @@ +with + +source AS ( + SELECT * + FROM {{ ref("int_ga4_events") }} + WHERE + page_location ilike '%apps.shopify.com%' + OR event_name ilike 'shopify%' + OR page_location ilike '%surface_%' + +) + +SELECT * +FROM source diff --git a/models/mesa/stg_ga_app_store_page_events.yml b/models/google_analytics/intermediate/int_ga_app_store_page_events.yml similarity index 93% rename from models/mesa/stg_ga_app_store_page_events.yml rename to models/google_analytics/intermediate/int_ga_app_store_page_events.yml index a1945ea..b1a64c0 100644 --- a/models/mesa/stg_ga_app_store_page_events.yml +++ b/models/google_analytics/intermediate/int_ga_app_store_page_events.yml @@ -1,6 +1,6 @@ version: 2 models: - - name: stg_ga_app_store_page_events + - name: int_ga_app_store_page_events columns: - name: user_pseudo_id description: the anonymouse google analytics user id diff --git a/models/google_analytics/intermediate/int_ga_attribution.sql b/models/google_analytics/intermediate/int_ga_attribution.sql index 25416d8..e0aa925 100644 --- a/models/google_analytics/intermediate/int_ga_attribution.sql +++ b/models/google_analytics/intermediate/int_ga_attribution.sql @@ -13,23 +13,49 @@ with 0 ) as ga4_sessions_til_install from shops - left join {{ ref("stg_ga_session_starts") }} using (shop_subdomain) + left join {{ ref("int_ga_session_starts") }} using (shop_subdomain) group by 1 ), - first_touches_ga4 as (select * from {{ ref("stg_ga_first_visits") }}), + first_touches_ga4 as (select * from {{ ref("int_ga_first_visits") }}), last_touches_ga4 as ( - select * from {{ ref("stg_last_touch_ga_sessions_before_install") }} + select * from {{ ref("int_last_touch_ga_sessions_before_install") }} ), - final as ( + combined as ( - select * exclude (user_pseudo_id) - from first_touches_ga4 + select * + FROM first_touches_ga4 left join last_touches_ga4 using (shop_subdomain) left join session_counts using (shop_subdomain) + ), + +final AS ( + SELECT * + REPLACE ( + {%- set reformatted_fields = [] -%} + {%- for prefix in ['first_touch', 'last_touch'] -%} + {%- for midfix in ['traffic_source', 'manual', 'param'] -%} + {%- for endfix in ['source', 'medium', 'campaign_name', 'term', 'content' ] -%} + {%- if (endfix=='campaign_name') -%} + {% if midfix=='traffic_source' %} + {% set endfix = 'name' %} + {%- elif midfix=='param' %} + {% set endfix = 'campaign' %} + {%- endif %} + {%- elif (midfix=='traffic_source' and (endfix=='term' or endfix=='content')) -%} + {%- continue -%} + {%- endif -%} + {%- set column_name = [prefix, midfix, endfix] | join('_') -%} + {%- do reformatted_fields.append("initcap(replace(" ~ column_name ~ ", '_', ' ')) as " ~ column_name) -%} + {% endfor %} + {% endfor %} + {% endfor %} + {{ reformatted_fields | join(',\n ') }} ) + FROM combined +) select * EXCLUDE (parsed_url) from final diff --git a/models/mesa/int_ga_attribution.yml b/models/google_analytics/intermediate/int_ga_attribution.yml similarity index 95% rename from models/mesa/int_ga_attribution.yml rename to models/google_analytics/intermediate/int_ga_attribution.yml index 23417d9..b394469 100644 --- a/models/mesa/int_ga_attribution.yml +++ b/models/google_analytics/intermediate/int_ga_attribution.yml @@ -16,11 +16,11 @@ models: description: The path of the first touch. - name: first_touch_content description: The content that the shop was acquired through. - - name: first_touch_campaign + - name: first_touch_traffic_source_name description: The campaign that the shop was acquired through. - - name: first_touch_medium + - name: first_touch_traffic_source_medium description: The medium that the shop was acquired through. - - name: first_touch_source + - name: first_touch_traffic_source_source description: The source that the shop was acquired through. - name: first_touch_referrer_host description: The referrer host that referrered the shop's first visit. diff --git a/models/google_analytics/intermediate/int_ga_first_visits.sql b/models/google_analytics/intermediate/int_ga_first_visits.sql new file mode 100644 index 0000000..9dd394b --- /dev/null +++ b/models/google_analytics/intermediate/int_ga_first_visits.sql @@ -0,0 +1,17 @@ +WITH + first_visits AS ( + SELECT * + FROM {{ ref("int_ga4_events") }} + WHERE (event_name = 'first_visit') + ), + + formatted_first_visits AS ( + SELECT + shop_subdomain, + {{ get_prefixed_columns(ref('int_ga4_events'), 'first_touch', exclude=['event_name']) }} + FROM first_visits + ) + +SELECT * +FROM formatted_first_visits +QUALIFY ROW_NUMBER() OVER (PARTITION BY shop_subdomain ORDER BY first_touch_at_pt) = 1 diff --git a/models/google_analytics/intermediate/int_ga_install_events.sql b/models/google_analytics/intermediate/int_ga_install_events.sql new file mode 100644 index 0000000..6d583f5 --- /dev/null +++ b/models/google_analytics/intermediate/int_ga_install_events.sql @@ -0,0 +1,18 @@ +with + + installation_events as ( + select + * + from {{ ref("int_ga4_events") }} + where event_name = 'getmesa_install_convert' + ) + +select + * +from installation_events + +qualify + row_number() over ( + partition by shop_subdomain order by event_timestamp_pt asc + ) + = 1 diff --git a/models/google_analytics/intermediate/int_ga_session_starts.sql b/models/google_analytics/intermediate/int_ga_session_starts.sql new file mode 100644 index 0000000..8a8ac91 --- /dev/null +++ b/models/google_analytics/intermediate/int_ga_session_starts.sql @@ -0,0 +1,11 @@ +WITH + + session_starts AS ( + SELECT * EXCLUDE event_name + FROM {{ ref("int_ga4_events") }} + WHERE event_name = 'session_start' + ) + +SELECT + * +FROM session_starts diff --git a/models/mesa/stg_ga_session_starts.yml b/models/google_analytics/intermediate/int_ga_session_starts.yml similarity index 86% rename from models/mesa/stg_ga_session_starts.yml rename to models/google_analytics/intermediate/int_ga_session_starts.yml index 50883c7..eed9d26 100644 --- a/models/mesa/stg_ga_session_starts.yml +++ b/models/google_analytics/intermediate/int_ga_session_starts.yml @@ -1,8 +1,9 @@ version: 2 models: - - name: stg_ga_session_starts + - name: int_ga_session_starts columns: - name: user_pseudo_id + description: the anonymouse google analytics user id - name: page_location - name: event_timestamp_pt - name: page_url diff --git a/models/google_analytics/intermediate/int_last_touch_ga_sessions_before_install.sql b/models/google_analytics/intermediate/int_last_touch_ga_sessions_before_install.sql new file mode 100644 index 0000000..bc279b3 --- /dev/null +++ b/models/google_analytics/intermediate/int_last_touch_ga_sessions_before_install.sql @@ -0,0 +1,46 @@ +WITH + first_install_events AS ( + SELECT + * RENAME ( + event_timestamp_pt AS first_install_timestamp_pt + ) + FROM {{ ref("int_ga_install_events") }} + QUALIFY + ROW_NUMBER() OVER ( + PARTITION BY shop_subdomain + ORDER BY event_timestamp_pt + ) + = 1 + ), + + session_starts AS (SELECT * FROM {{ ref("int_ga_session_starts") }}), + + last_touch_sessions AS ( + SELECT * EXCLUDE (rn) + FROM + ( + SELECT + session_starts.*, + ROW_NUMBER() OVER ( + PARTITION BY first_install_events.shop_subdomain + ORDER BY session_starts.event_timestamp_pt DESC + ) AS rn + FROM session_starts + INNER JOIN first_install_events USING (shop_subdomain) + WHERE + session_starts.event_timestamp_pt + <= first_install_events.first_install_timestamp_pt + QUALIFY rn = 1 + ) AS t + ), + + formatted_last_touch_session_starts AS ( + + SELECT + shop_subdomain, + {{ get_prefixed_columns(ref('int_ga_session_starts'), 'last_touch') }} + FROM last_touch_sessions + ) + +SELECT * +FROM formatted_last_touch_session_starts diff --git a/models/mesa/stg_last_touch_ga_sessions_before_install.yml b/models/google_analytics/intermediate/int_last_touch_ga_sessions_before_install.yml similarity index 96% rename from models/mesa/stg_last_touch_ga_sessions_before_install.yml rename to models/google_analytics/intermediate/int_last_touch_ga_sessions_before_install.yml index 60f5c7e..c6208b8 100644 --- a/models/mesa/stg_last_touch_ga_sessions_before_install.yml +++ b/models/google_analytics/intermediate/int_last_touch_ga_sessions_before_install.yml @@ -1,6 +1,6 @@ version: 2 models: - - name: stg_last_touch_ga_sessions_before_install + - name: int_last_touch_ga_sessions_before_install columns: - name: shop_subdomain description: The foreign key for the Shop. diff --git a/models/google_analytics/mart/ga4_events.sql b/models/google_analytics/mart/ga4_events.sql index bb59932..8e0fa57 100644 --- a/models/google_analytics/mart/ga4_events.sql +++ b/models/google_analytics/mart/ga4_events.sql @@ -1,27 +1,12 @@ WITH -shop_anonymous_keys AS ( - SELECT * FROM {{ ref("stg_anonymous_to_known_user_matching") }} -), - ga4_events AS ( - SELECT * FROM {{ ref("stg_ga4_events") }} + SELECT * FROM {{ ref("int_ga4_events") }} ), final AS ( - SELECT - ga4_events.* EXCLUDE (shop_subdomain, shopify_id), - shop_anonymous_keys.shop_subdomain, - shop_anonymous_keys.shopify_id, - - -- URL parts - PARSE_URL(page_location) AS parsed_url, - parsed_url:host || '/' || parsed_url:path AS page_url, - parsed_url:host::STRING AS page_host, - '/' || parsed_url:path::STRING AS page_path, - '?' || parsed_url:query::STRING AS page_query + SELECT * FROM ga4_events - LEFT JOIN shop_anonymous_keys USING (user_pseudo_id) ) -SELECT * EXCLUDE (parsed_url) +SELECT * FROM final diff --git a/models/google_analytics/staging/_stg_anonymous_to_known_user_matching_schema.yml b/models/google_analytics/staging/_stg_anonymous_to_known_user_matching_schema.yml index 8d335b2..92d578a 100644 --- a/models/google_analytics/staging/_stg_anonymous_to_known_user_matching_schema.yml +++ b/models/google_analytics/staging/_stg_anonymous_to_known_user_matching_schema.yml @@ -6,12 +6,19 @@ models: tests: - dbt_expectations.expect_table_row_count_to_be_between: min_value: 1000 + + - dbt_expectations.expect_table_row_count_to_be_between: + min_value: 1 + config: + where: "shopify_id = '78775419205'" + + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - USER_PSEUDO_ID + - SHOP_SUBDOMAIN columns: - name: USER_PSEUDO_ID description: The anonymouse Google Analytics user ID - tests: - - not_null - # - unique - name: SHOP_SUBDOMAIN description: The foreign key of the Shop. tests: diff --git a/models/google_analytics/staging/stg_anonymous_to_known_user_matching.sql b/models/google_analytics/staging/stg_anonymous_to_known_user_matching.sql index 1ffd900..3a9828f 100644 --- a/models/google_analytics/staging/stg_anonymous_to_known_user_matching.sql +++ b/models/google_analytics/staging/stg_anonymous_to_known_user_matching.sql @@ -1,29 +1,31 @@ -with - user_id_matches as ( - select user_pseudo_id, shop_subdomain, shopify_id - from {{ ref("stg_ga4_events") }} - where shop_subdomain is not NULL or shopify_id is not NULL - qualify - row_number() over ( - partition by user_pseudo_id, shop_subdomain, shopify_id - order by event_timestamp_pt - ) - = 1 - ), +WITH +ga4_events AS ( + SELECT * + FROM {{ ref("stg_ga4_events") }} +), - shops as (select shop_subdomain, shopify_id from {{ ref("stg_shops") }}), +shops AS (SELECT shop_subdomain, shopify_id FROM {{ ref("stg_shops") }}), - final as ( +final AS ( - select user_id_matches.user_pseudo_id, shops.shopify_id, shops.shop_subdomain - from user_id_matches - inner join - shops - on ( - user_id_matches.shop_subdomain = shops.shop_subdomain - or user_id_matches.shopify_id = shops.shopify_id - ) - ) + SELECT + ga4_events.user_pseudo_id, + shops.shopify_id::STRING AS shopify_id, + shops.shop_subdomain + FROM shops + LEFT JOIN ga4_events + ON ( + shops.shop_subdomain = ga4_events.shop_subdomain + OR + ga4_events.shopify_id::STRING = shops.shopify_id::STRING + ) + QUALIFY + ROW_NUMBER() OVER ( + PARTITION BY shops.shop_subdomain, user_pseudo_id + ORDER BY true + ) + = 1 +) -select * -from final +SELECT * +FROM final diff --git a/models/google_analytics/staging/stg_ga4_events.sql b/models/google_analytics/staging/stg_ga4_events.sql index e1ef99f..49a65d0 100644 --- a/models/google_analytics/staging/stg_ga4_events.sql +++ b/models/google_analytics/staging/stg_ga4_events.sql @@ -7,29 +7,53 @@ with __hevo__ingested_at, __hevo__loaded_at, surface_detail, - surface_type + surface_type, + page_referrer, + user_id, + page_location, + shop_id ) rename ( + __hevo_id as event_id, name as traffic_source_name, medium as traffic_source_medium, source as traffic_source_source, category as device_category, - __hevo_id as event_id, - user_id as shop_subdomain, - shop_id as shopify_id + language as device_language, + country AS location_country, + city AS location_city, + continent AS location_continent, + metro AS location_metro ), + shop_id::STRING as shopify_id, {{ pacific_timestamp("TO_TIMESTAMP(event_timestamp)") }} - as event_timestamp_pt, + as event_timestamp_pt, + + {# Conditionally set shop_subdomain #} + coalesce(user_id, COALESCE( + NULLIF(REGEXP_SUBSTR(page_location, 'shop=(.*?)\.myshopify\.com', 1, 1, 'ie'), ''), + NULLIF(REGEXP_SUBSTR(page_referrer, 'shop=(.*?)\.myshopify\.com', 1, 1, 'ie'), '') + )) AS shop_subdomain, + + {# Page components #} + parse_url(page_location) as parsed_url, + parsed_url:host::STRING as page_location_host, + '/' || parsed_url:path as page_location_path, + '?' || parsed_url:query as page_location_query, + page_location_host || page_location_path AS page_location_url, + page_location_host || page_location_path || COALESCE(page_location_query, '') AS page_location, {# Attribution #} - parse_url(page_location) as page_params, - page_params:parameters:utm_content::STRING as param_content, - page_params:parameters:utm_term::STRING as param_term, - page_params:parameters:page_referrer::STRING as referrer, - page_params:host::STRING as referrer_host, - page_params:parameters:referrer_source::STRING as referrer_source, - page_params:parameters:referrer_medium::STRING as referrer_medium, - page_params:parameters:referrer_term::STRING as referrer_term, + parsed_url:parameters:utm_content::STRING as param_content, + parsed_url:parameters:utm_term::STRING as param_term, + + {# Referrer #} + parse_url(page_referrer) as parsed_referrer, + parsed_referrer:host::STRING as referrer_host, + '/' || parsed_referrer:path as referrer_path, + '?' || parsed_referrer:query as referrer_query, + referrer_host || referrer_path AS referrer_url, + referrer_host || referrer_path || COALESCE(referrer_query, '') AS referrer_full, {# App Store #} TRIM( @@ -38,7 +62,7 @@ with LOWER( COALESCE( surface_detail, - page_params:parameters:surface_detail::STRING + parsed_url:parameters:surface_detail::STRING ) ), 'undefined' @@ -46,13 +70,13 @@ with ) ) AS app_store_surface_detail, coalesce( - nullif(surface_type, ''), page_params:parameters:surface_type::STRING + nullif(surface_type, ''), parsed_url:parameters:surface_type::STRING ) as app_store_surface_type, - page_params:parameters:surface_intra_position::STRING + parsed_url:parameters:surface_intra_position::STRING as app_store_surface_intra_position, - page_params:parameters:surface_inter_position::STRING + parsed_url:parameters:surface_inter_position::STRING as app_store_surface_inter_position, - page_params:parameters:locale::STRING as app_store_locale + parsed_url:parameters:locale::STRING as app_store_locale FROM {{ source("mesa_ga4", "events") }} WHERE ga_session_id is not NULL AND (page_location IS NULL OR NOT page_location ilike '%.pages.dev%') ) @@ -66,15 +90,17 @@ with "traffic_source_name", "traffic_source_source", "traffic_source_medium", - "referrer", "referrer_host", - "referrer_source", - "referrer_medium", - "shop_subdomain", + "referrer_full", + "referrer_url", + "referrer_query", + "referrer_path", + "shop_subdomain" ] %} select * - exclude page_params replace ( + exclude (parsed_url, parsed_referrer) + replace ( {% for field in not_empty_string_fields %} nullif({{ field }}, '') as {{ field }}{% if not loop.last %},{% endif %} {% endfor %} diff --git a/models/google_analytics/staging/stg_ga_app_store_page_events.sql b/models/google_analytics/staging/stg_ga_app_store_page_events.sql deleted file mode 100644 index d90f624..0000000 --- a/models/google_analytics/staging/stg_ga_app_store_page_events.sql +++ /dev/null @@ -1,65 +0,0 @@ -with - user_matching AS (SELECT * FROM {{ ref("stg_anonymous_to_known_user_matching") }}), - - source AS ( - SELECT - user_pseudo_id, - shop_subdomain, - event_name, - shopify_id, - event_timestamp_pt, - page_location, - - {# Attribution #} - COALESCE(traffic_source_name, param_campaign) AS utm_campaign, - COALESCE(traffic_source_medium, param_medium) AS utm_medium, - COALESCE(traffic_source_source, param_source) AS utm_source, - device_category, - param_content AS utm_content, - param_term AS utm_term, - * ilike 'referrer%', - - {# App Store #} - * ilike 'app_store%' - FROM {{ ref("stg_ga4_events") }} - WHERE - page_location ilike '%apps.shopify.com%' - OR event_name ilike 'shopify%' - OR page_location ilike '%surface_%' - - ), - - final AS ( - - SELECT - source.* exclude (utm_source, utm_campaign, shop_subdomain), - user_matching.shop_subdomain, - CASE - WHEN app_store_surface_type IS NOT NULL - THEN 'Shopify App Store' - ELSE utm_source - END AS utm_source, - - CASE - WHEN app_store_surface_intra_position IS NOT NULL - THEN - CONCAT( - 'Intra pos:', - app_store_surface_intra_position, - ' / Inter pos:', - app_store_surface_inter_position - ) - ELSE utm_campaign - END AS utm_campaign - FROM source - INNER JOIN - user_matching - ON ( - source.user_pseudo_id = user_matching.user_pseudo_id - OR source.shopify_id = user_matching.shopify_id - OR source.shop_subdomain = user_matching.shop_subdomain - ) - ) - -SELECT * -FROM final diff --git a/models/google_analytics/staging/stg_ga_first_visits.sql b/models/google_analytics/staging/stg_ga_first_visits.sql deleted file mode 100644 index 90f0bcd..0000000 --- a/models/google_analytics/staging/stg_ga_first_visits.sql +++ /dev/null @@ -1,67 +0,0 @@ -WITH - shop_anonymous_keys AS ( - SELECT * FROM {{ ref("stg_anonymous_to_known_user_matching") }} - ), - - first_visits AS ( - SELECT * - FROM {{ ref("stg_ga4_events") }} - WHERE (event_name = 'first_visit') AND NOT (page_location ILIKE '%.pages.dev%') - ), - - shop_first_visits AS ( - - SELECT - {# App Store #} - * ILIKE 'app_store%', - - {# Identifiers #} - user_pseudo_id::STRING AS user_pseudo_id, - page_location::STRING AS page_location, - event_timestamp_pt, - - {# Attribution #} - param_content AS utm_content, - param_term AS utm_term, - COALESCE(traffic_source_name, param_campaign) AS utm_campaign, - COALESCE(traffic_source_medium, param_medium) AS utm_medium, - COALESCE(traffic_source_source, param_source) AS utm_source, - device_category, - page_referrer AS first_touch_referrer, - parse_url(first_touch_referrer):host::STRING AS first_touch_referrer_host - - FROM first_visits - ), - - formatted_first_visits AS ( - SELECT - user_pseudo_id, - event_timestamp_pt AS first_touch_at_pt, - page_location AS acquisition_first_page_path, - utm_content AS first_touch_content, - utm_campaign AS first_touch_campaign, - utm_medium AS first_touch_medium, - utm_source AS first_touch_source, - app_store_surface_detail AS first_touch_app_surface_detail, - app_store_surface_type AS first_touch_app_store_surface_type, - app_store_surface_intra_position - AS first_touch_app_store_surface_intra_position, - app_store_surface_inter_position - AS first_touch_app_store_surface_inter_position, - app_store_locale AS first_touch_app_store_locale, - first_touch_referrer, - first_touch_referrer_host, - device_category AS first_touch_device_category, - - parse_url(page_location) AS parsed_url, - parsed_url:host || '/' || parsed_url:path AS first_touch_url, - parsed_url:host::STRING AS first_touch_host, - '/' || parsed_url:path::STRING AS first_touch_path, - '?' || parsed_url:query::STRING AS first_touch_query - FROM shop_first_visits - ) - -SELECT * EXCLUDE (parsed_url) -FROM formatted_first_visits -INNER JOIN shop_anonymous_keys USING (user_pseudo_id) -QUALIFY ROW_NUMBER() OVER (PARTITION BY shop_subdomain ORDER BY first_touch_at_pt) = 1 diff --git a/models/google_analytics/staging/stg_ga_install_events.sql b/models/google_analytics/staging/stg_ga_install_events.sql deleted file mode 100644 index b3fe0fe..0000000 --- a/models/google_analytics/staging/stg_ga_install_events.sql +++ /dev/null @@ -1,27 +0,0 @@ -with - user_matching as (select * from {{ ref("stg_anonymous_to_known_user_matching") }}), - - installation_events as ( - select user_pseudo_id, shop_subdomain, shopify_id, event_timestamp_pt - from {{ ref("stg_ga4_events") }} - where event_name = 'getmesa_install_convert' - ) - -select - installation_events.* exclude (shop_subdomain, shopify_id) - rename event_timestamp_pt as getmesa_install_convert_event_timestamp_pt, - user_matching.shop_subdomain, - user_matching.shopify_id -from installation_events -inner join - user_matching - on ( - installation_events.user_pseudo_id = user_matching.user_pseudo_id - or installation_events.shopify_id = user_matching.shopify_id - or installation_events.shop_subdomain = user_matching.shop_subdomain - ) -qualify - row_number() over ( - partition by user_matching.shop_subdomain order by event_timestamp_pt asc - ) - = 1 diff --git a/models/google_analytics/staging/stg_last_touch_ga_sessions_before_install.sql b/models/google_analytics/staging/stg_last_touch_ga_sessions_before_install.sql deleted file mode 100644 index 5158de9..0000000 --- a/models/google_analytics/staging/stg_last_touch_ga_sessions_before_install.sql +++ /dev/null @@ -1,66 +0,0 @@ -WITH - first_install_events AS ( - SELECT - * RENAME ( - getmesa_install_convert_event_timestamp_pt AS first_install_timestamp_pt - ) - FROM {{ ref("stg_ga_install_events") }} - QUALIFY - ROW_NUMBER() OVER ( - PARTITION BY shop_subdomain - ORDER BY getmesa_install_convert_event_timestamp_pt - ) - = 1 - ), - - session_starts AS (SELECT * FROM {{ ref("stg_ga_session_starts") }}), - - last_touch_sessions AS ( - SELECT * EXCLUDE (rn) - FROM - ( - SELECT - session_starts.*, - ROW_NUMBER() OVER ( - PARTITION BY first_install_events.shop_subdomain - ORDER BY session_starts.event_timestamp_pt DESC - ) AS rn - FROM session_starts - INNER JOIN first_install_events USING (shop_subdomain) - WHERE - session_starts.event_timestamp_pt - <= first_install_events.first_install_timestamp_pt - QUALIFY rn = 1 - ) AS t - ), - - formatted_last_touch_session_starts AS ( - SELECT - shop_subdomain, - event_timestamp_pt AS last_touch_at_pt, - utm_content AS last_touch_content, - utm_campaign AS last_touch_campaign, - utm_medium AS last_touch_medium, - utm_source AS last_touch_source, - app_store_surface_detail AS last_touch_app_store_surface_detail, - app_store_surface_type AS last_touch_app_store_surface_type, - app_store_surface_intra_position - AS last_touch_app_store_surface_intra_position, - app_store_locale AS last_touch_app_store_locale, - app_store_surface_inter_position - AS last_touch_app_store_surface_inter_position, - page_referrer AS last_touch_referrer, - PARSE_URL(last_touch_referrer):host::STRING AS last_touch_referrer_host, - device_category AS last_touch_device_category, - - PARSE_URL(page_location) AS parsed_url, - parsed_url:host || '/' || parsed_url:path AS last_touch_url, - parsed_url:host::STRING AS last_touch_host, - '/' || parsed_url:path::STRING AS last_touch_path, - '?' || parsed_url:query::STRING AS last_touch_query - - FROM last_touch_sessions - ) - -SELECT * -FROM formatted_last_touch_session_starts diff --git a/models/mesa/_stg_mesa_install_records_schema.yml b/models/mesa/_stg_mesa_install_records_schema.yml new file mode 100644 index 0000000..bf0a9e6 --- /dev/null +++ b/models/mesa/_stg_mesa_install_records_schema.yml @@ -0,0 +1,12 @@ +version: 2 +models: + - name: stg_mesa_install_records + tests: + - dbt_expectations.expect_table_row_count_to_be_between: + min_value: 200 + columns: + - name: shop_subdomain + tests: + - unique + - not_null + description: The foreign key for the Shop. diff --git a/models/mesa/ga4_events.yml b/models/mesa/ga4_events.yml index 568c1b3..29fd2f8 100644 --- a/models/mesa/ga4_events.yml +++ b/models/mesa/ga4_events.yml @@ -2,40 +2,46 @@ version: 2 models: - name: ga4_events columns: - - name: page_location + - name: shop_subdomain + description: The subdomain of the shop. - name: page_title - name: traffic_source_name - name: event_name - tests: - - dbt_expectations.expect_column_distinct_count_to_be_greater_than: - value: 0 - row_condition: "event_name = 'shopify_app_install'" - - name: user_pseudo_id - description: the anonymouse google analytics user id - name: traffic_source_medium - name: traffic_source_source - name: device_category - name: event_id - - name: shop_subdomain - description: The foreign key of the Shop. - name: param_campaign - name: param_source - name: param_medium - - name: page_referrer - - name: shopify_id - description: The official shopify identifier for the shop. - name: ga_session_id - name: ga_session_number - - name: app_store_surface_type + - name: location_continent + - name: location_country + - name: location_city + - name: location_metro + - name: device_language + - name: manual_campaign_name + - name: gclid + - name: manual_medium + - name: manual_source + - name: manual_term + - name: manual_content - name: event_timestamp_pt + - name: page_location_host + - name: page_location_path + - name: page_location_query + - name: page_location_url + - name: page_location - name: param_content - name: param_term - - name: referrer - name: referrer_host - - name: referrer_source - - name: referrer_medium - - name: referrer_term + - name: referrer_path + - name: referrer_query + - name: referrer_url + - name: referrer_full - name: app_store_surface_detail + - name: app_store_surface_type - name: app_store_surface_intra_position - name: app_store_surface_inter_position - name: app_store_locale diff --git a/models/mesa/int_ga4_events.yml b/models/mesa/int_ga4_events.yml new file mode 100644 index 0000000..e552c32 --- /dev/null +++ b/models/mesa/int_ga4_events.yml @@ -0,0 +1,47 @@ +version: 2 +models: + - name: int_ga4_events + columns: + - name: shop_subdomain + description: The subdomain of the shop. + - name: page_title + - name: traffic_source_name + - name: event_name + - name: traffic_source_medium + - name: traffic_source_source + - name: device_category + - name: event_id + - name: param_campaign + - name: param_source + - name: param_medium + - name: ga_session_id + - name: ga_session_number + - name: location_continent + - name: location_country + - name: location_city + - name: location_metro + - name: device_language + - name: manual_campaign_name + - name: gclid + - name: manual_medium + - name: manual_source + - name: manual_term + - name: manual_content + - name: event_timestamp_pt + - name: page_location_host + - name: page_location_path + - name: page_location_query + - name: page_location_url + - name: page_location + - name: param_content + - name: param_term + - name: referrer_host + - name: referrer_path + - name: referrer_query + - name: referrer_url + - name: referrer_full + - name: app_store_surface_detail + - name: app_store_surface_type + - name: app_store_surface_intra_position + - name: app_store_surface_inter_position + - name: app_store_locale diff --git a/models/mesa/int_segment_attribution.yml b/models/mesa/int_segment_attribution.yml index 109075e..1b22cd6 100644 --- a/models/mesa/int_segment_attribution.yml +++ b/models/mesa/int_segment_attribution.yml @@ -16,11 +16,11 @@ models: description: The path of the first touch. - name: first_touch_content description: The content that the shop was acquired through. - - name: first_touch_campaign + - name: first_touch_traffic_source_name description: The campaign that the shop was acquired through. - - name: first_touch_medium + - name: first_touch_traffic_source_medium description: The medium that the shop was acquired through. - - name: first_touch_source + - name: first_touch_traffic_source_source description: The source that the shop was acquired through. - name: first_touch_referrer_host description: The referrer host that referrered the shop's first visit. diff --git a/models/mesa/int_simplified_shop_attribution.yml b/models/mesa/int_simplified_shop_attribution.yml new file mode 100644 index 0000000..4c07d72 --- /dev/null +++ b/models/mesa/int_simplified_shop_attribution.yml @@ -0,0 +1,23 @@ +version: 2 +models: + - name: int_simplified_shop_attribution + columns: + - name: shop_subdomain + description: The subdomain of the shop. + - name: acq_acquisition_template + - name: acq_has_app_store_organic_click + - name: acq_unified_traffic_source + - name: acq_unified_traffic_medium + - name: acq_unified_traffic_campaign + - name: acq_unified_traffic_url + - name: acq_unified_traffic_path + - name: acq_unified_traffic_page_host + - name: acq_unified_first_touch_at_pt + - name: acq_unified_app_store_surface_type + - name: acq_unified_app_store_surface_detail + - name: acq_unified_referrer_host + - name: acq_is_blog_referral + - name: acq_days_to_install + - name: acq_is_app_store_search_ad_referral + - name: acq_referrer_medium + - name: acq_referrer_source diff --git a/models/mesa/intermediate/_int_shop_install_sources.yml b/models/mesa/intermediate/_int_shop_install_sources.yml index 2547ae0..b2aff82 100644 --- a/models/mesa/intermediate/_int_shop_install_sources.yml +++ b/models/mesa/intermediate/_int_shop_install_sources.yml @@ -10,29 +10,30 @@ models: - name: shop_subdomain tests: - not_null + - unique description: The foreign key for the Shop. - - name: first_touch_campaign + - name: ga_first_touch_traffic_source_name description: The campaign that the shop was acquired through. - - name: first_touch_content + - name: ga_first_touch_content description: The content that the shop was acquired through. - - name: first_touch_referrer + - name: ga_first_touch_referrer description: The referrer URL that referred the Shop's first visit. - - name: first_touch_referrer_host + - name: ga_first_touch_referrer_host description: The referrer host that referrered the shop's first visit. - - name: first_touch_first_page_path + - name: ga_first_touch_first_page_path description: The first page path that the shop was acquired through. - - name: first_touch_source + - name: ga_first_touch_traffic_source_source description: The source that the shop was acquired through. - - name: first_touch_medium + - name: ga_first_touch_traffic_source_medium tests: - not_null: config: - where: shop_subdomain IN ('hotrocksjewelry', 'hydromony') + where: shop_subdomain IN ('locker-toys', 'drink-renude') - dbt_expectations.expect_column_values_to_not_be_in_set: value_set: - "" description: The medium that the shop was acquired through. - - name: first_touch_source_medium + - name: ga_first_touch_traffic_source_source_medium description: The source & medium that drove the Shop's first visit. - name: is_blog_referral tests: @@ -40,7 +41,7 @@ models: description: Whether the Shop was referred/entered the marketing site by a blog post. - - name: first_touch_template + - name: ga_first_touch_template description: The template the Shop intended to use when they first installed the app. diff --git a/models/mesa/intermediate/int_shop_install_sources.sql b/models/mesa/intermediate/int_shop_install_sources.sql index c854bd3..c06ec66 100644 --- a/models/mesa/intermediate/int_shop_install_sources.sql +++ b/models/mesa/intermediate/int_shop_install_sources.sql @@ -12,358 +12,219 @@ [ ] Look for any and all pre-install search_ad surface_type events. #} with - shops as (select shop_subdomain, first_installed_at_pt from {{ ref("stg_shops") }}), - - ga_attribution as (select * from {{ ref("int_ga_attribution") }}), - - segment_attribution as (select * from {{ ref("int_segment_attribution") }}), - - app_store_install_events as ( - select - shop_subdomain, - {% set column_names = dbt_utils.get_filtered_columns_in_relation( - from=ref("stg_ga_app_store_page_events"), - except=[ - "user_pseudo_id", - "shopify_id", - "shop_subdomain", - "event_name", - "referrer_term", - "app_store_surface_intra_position", - "app_store_surface_inter_position", - "utm_medium", - "utm_campaign", - ], - ) %} - {% for column_name in column_names %} - {{ column_name }} as app_store_install_{{ column_name }} - {%- if not loop.last %},{% endif %} - {% endfor %}, - initcap( - utm_source || ' - ' || utm_medium - ) as app_store_install_source_medium - from {{ ref("stg_ga_app_store_page_events") }} - where event_name = 'shopify_app_install' - qualify - row_number() over ( - partition by shop_subdomain order by event_timestamp_pt asc - ) - = 1 - ), - - app_store_ad_clicks as ( - select - shop_subdomain, - {% set column_names = dbt_utils.get_filtered_columns_in_relation( - from=ref("stg_ga_app_store_page_events"), - except=[ - "user_pseudo_id", - "shopify_id", - "shop_subdomain", - "event_name", - "surface_type", - "surface_detail", - "utm_term", - "referrer", - "referrer_term", - ], - ) %} - {% for column_name in column_names %} - {{ column_name }} as app_store_ad_click_{{ column_name }} - {%- if not loop.last %},{% endif %} - {% endfor %}, - initcap( - utm_source || ' - ' || utm_medium - ) as app_store_ad_click_source_medium - from {{ ref("stg_ga_app_store_page_events") }} - where page_location ilike '%search_ad%' or event_name = 'shopify_ad_click' - qualify - row_number() over ( - partition by shop_subdomain order by event_timestamp_pt asc - ) - = 1 - ), - - app_store_ad_click_counts as ( - select - shop_subdomain, - count_if( - app_store_ad_click_event_timestamp_pt - <= first_installed_at_pt + interval '60min' - ) - > 0 as app_store_did_click_ad_before_install, - count(app_store_ad_clicks.app_store_ad_click_page_location) - > 0 as app_store_did_click_ad - from shops - left join app_store_ad_clicks using (shop_subdomain) - group by 1 - ), - - app_store_organic_clicks as ( - select - shop_subdomain, - {% set column_names = dbt_utils.get_filtered_columns_in_relation( - from=ref("stg_ga_app_store_page_events"), - except=[ - "user_pseudo_id", - "shopify_id", - "shop_subdomain", - "event_name", - "name", - "referrer_source", - "utm_term", - "referrer", - "referrer_medium", - ], - ) %} - {% for column_name in column_names %} - {{ column_name }} as app_store_organic_click_{{ column_name }} - {%- if not loop.last %},{% endif %} - {% endfor %} - from {{ ref("stg_ga_app_store_page_events") }} - where - page_location ilike '%surface_type=%' - and page_location not ilike '%search_ad%' - and event_name = 'session_start' - qualify - row_number() over ( - partition by shop_subdomain order by event_timestamp_pt asc - ) - = 1 - ), - - mesa_install_events as ( - select - uuid as shop_subdomain, - {% set column_names = dbt_utils.get_filtered_columns_in_relation( - from=source("mongo_sync", "mesa_install_events"), - except=[ - "created_at", - "template", - "state", - "uuid", - "mesa_id", - "__hevo__ingested_at", - "__hevo__loaded_at", - "__hevo__database_name", - "updated_at", - "utm_term", - "route", - "ip", - "__hevo__marked_deleted", - "_created_at", - "_id", - ], - ) %} - {% for column_name in column_names %} - iff( - {{ column_name }}::varchar = '', null, {{ column_name }} - ) as mesa_install_event_{{ column_name }} - {%- if not loop.last %},{% endif %} - {% endfor %}, - {{ pacific_timestamp("created_at") }} as mesa_install_event_timestamp_pt, - template as acquisition_template, - 'mesa_install_event' as install_event_info_source - from {{ source("mongo_sync", "mesa_install_events") }} - where install_completed - ), - - formatted_install_events as ( - select mesa_install_events.* - from mesa_install_events - left join shops using (shop_subdomain) - having - mesa_install_event_timestamp_pt - <= first_installed_at_pt + interval '60seconds' - qualify - row_number() over ( - partition by shop_subdomain order by mesa_install_event_timestamp_pt asc - ) - = 1 - ), - - data_pipeline_attributions as ( - select - * rename ga4_sessions_til_install as sessions_til_install, - 'ga4' as install_event_info_source - from ga_attribution - - union - - select - * rename segment_sessions_til_install as sessions_til_install, - 'segment' as install_event_info_source - from segment_attribution - ), - - combined_attribution as ( - select - shops.shop_subdomain, - data_pipeline_attributions.* exclude ( - shop_subdomain, - first_touch_campaign, - last_touch_campaign, - first_touch_medium, - last_touch_medium, - first_touch_source, - last_touch_source, - install_event_info_source - ), - coalesce( - first_touch_campaign, mesa_install_event_utm_campaign - ) as first_touch_campaign, - coalesce( - last_touch_campaign, mesa_install_event_utm_campaign - ) as last_touch_campaign, - coalesce( - first_touch_medium, mesa_install_event_utm_medium - ) as first_touch_medium, - coalesce( - last_touch_medium, mesa_install_event_utm_medium - ) as last_touch_medium, - coalesce( - first_touch_source, mesa_install_event_utm_source - ) as first_touch_source, - coalesce( - last_touch_source, mesa_install_event_utm_source - ) as last_touch_source, - coalesce( - data_pipeline_attributions.install_event_info_source, - formatted_install_events.install_event_info_source - ) as install_event_info_source, - formatted_install_events.* exclude (install_event_info_source) - from shops - left join formatted_install_events using (shop_subdomain) - left join data_pipeline_attributions using (shop_subdomain) - having - first_touch_at_pt is null - or first_touch_at_pt <= first_installed_at_pt + interval '60min' - qualify - row_number() over ( - partition by shop_subdomain order by first_touch_at_pt asc - ) - = 1 - ), - - referrer_mapping as (select * from {{ ref("referrer_mapping") }}), - - combined as ( - select - shop_subdomain, - combined_attribution.* exclude ( - shop_subdomain, - first_touch_medium, - last_touch_medium, - first_touch_source, - last_touch_source - ) replace ( - initcap( - replace(first_touch_campaign, '_', ' ') - ) as first_touch_campaign, - initcap(replace(last_touch_campaign, '_', ' ')) as last_touch_campaign - ), - initcap( - replace( - coalesce(first_touch_referrer_mapping.medium, first_touch_medium), - '_', - ' ' - ) - ) as first_touch_medium, - initcap( - replace( - coalesce(last_touch_referrer_mapping.medium, last_touch_medium), - '_', - ' ' +shops as (select shop_subdomain, first_installed_at_pt from {{ ref("stg_shops") }}), + +ga_attribution as ( + select + shop_subdomain, + {{ get_prefixed_columns(ref('int_ga_attribution'), 'ga') }} + from {{ ref("int_ga_attribution") }} +), + +segment_attribution as ( + select + shop_subdomain, + {{ get_prefixed_columns(ref('int_segment_attribution'), 'segment') }} + from {{ ref("int_segment_attribution") }} +), + +app_store_attribution AS ( + SELECT * + FROM {{ ref('int_app_store_attribution') }} +), + +mesa_install_records as ( + SELECT * FROM {{ ref("stg_mesa_install_records") }} +), + +formatted_install_records as ( + select mesa_install_records.* + from mesa_install_records + left join shops using (shop_subdomain) + having + mesa_install_record_at_pt + <= first_installed_at_pt + interval '60seconds' + qualify + row_number() over ( + partition by shop_subdomain order by mesa_install_record_at_pt asc + ) + = 1 +), + +combined_attribution as ( + select + * EXCLUDE (first_installed_at_pt), + REPLACE(COALESCE( + ga_first_touch_traffic_source_source, + ga_first_touch_param_source, + ga_first_touch_manual_source, + segment_first_touch_traffic_source_source, + app_store_install_traffic_source_source, + app_store_install_param_source, + app_store_install_manual_source, + app_store_ad_click_traffic_source_source, + app_store_ad_click_param_source, + app_store_ad_click_manual_source, + app_store_organic_click_traffic_source_source, + app_store_organic_click_param_source, + app_store_organic_click_manual_source, + mesa_install_record_utm_source, + ga_last_touch_traffic_source_source, + ga_last_touch_param_source, + ga_last_touch_manual_source, + segment_last_touch_traffic_source_source + ), 'www.', '') AS unified_traffic_source, + COALESCE( + ga_first_touch_traffic_source_medium, + ga_first_touch_param_medium, + ga_first_touch_manual_medium, + app_store_install_traffic_source_medium, + app_store_install_param_medium, + app_store_install_manual_medium, + segment_first_touch_traffic_source_medium, + app_store_ad_click_traffic_source_medium, + app_store_ad_click_param_medium, + app_store_ad_click_manual_medium, + app_store_organic_click_traffic_source_medium, + app_store_organic_click_param_medium, + app_store_organic_click_manual_medium, + mesa_install_record_utm_medium, + ga_last_touch_traffic_source_medium, + ga_last_touch_param_medium, + ga_last_touch_manual_medium, + segment_last_touch_traffic_source_medium + ) AS unified_traffic_medium, + COALESCE( + ga_first_touch_traffic_source_name, + ga_first_touch_param_campaign, + ga_first_touch_manual_campaign_name, + app_store_install_traffic_source_name, + app_store_install_param_campaign, + app_store_install_manual_campaign_name, + segment_first_touch_traffic_source_name, + app_store_ad_click_traffic_source_name, + app_store_ad_click_param_campaign, + app_store_ad_click_manual_campaign_name, + app_store_organic_click_traffic_source_name, + app_store_organic_click_param_campaign, + app_store_organic_click_manual_campaign_name, + mesa_install_record_utm_campaign, + ga_last_touch_traffic_source_name, + ga_last_touch_param_campaign, + ga_last_touch_manual_campaign_name, + segment_last_touch_traffic_source_name + ) AS unified_traffic_campaign, + COALESCE( + ga_first_touch_page_location, + segment_first_touch_url, + ga_last_touch_page_location, + segment_last_touch_url + ) AS unified_traffic_url, + COALESCE( + ga_first_touch_page_location_path, + segment_first_touch_path, + ga_last_touch_page_location_path, + segment_last_touch_path + ) AS unified_traffic_path, + COALESCE( + ga_first_touch_page_location_host, + segment_first_touch_host, + ga_last_touch_page_location_host, + segment_last_touch_host + ) AS unified_traffic_page_host, + LEAST( + ga_first_touch_at_pt, + segment_first_touch_at_pt, + ga_last_touch_at_pt, + segment_last_touch_at_pt, + app_store_install_at_pt, + app_store_ad_click_at_pt, + app_store_organic_click_at_pt, + mesa_install_record_at_pt + ) AS unified_first_touch_at_pt, + COALESCE( + ga_first_touch_app_store_surface_type, + ga_last_touch_app_store_surface_type, + app_store_ad_click_app_store_surface_type, + app_store_organic_click_app_store_surface_type + ) AS unified_app_store_surface_type, + COALESCE( + ga_first_touch_app_store_surface_detail, + ga_last_touch_app_store_surface_detail, + app_store_ad_click_app_store_surface_detail, + app_store_organic_click_app_store_surface_detail + ) AS unified_app_store_surface_detail, + REPLACE(COALESCE( + ga_first_touch_referrer_host, + ga_last_touch_referrer_host, + segment_first_touch_referrer_host, + segment_last_touch_referrer_host, + app_store_install_referrer_host, + app_store_ad_click_referrer_host, + app_store_organic_click_referrer_host + ), 'www.', '') AS unified_referrer_host + from shops + left join formatted_install_records using (shop_subdomain) + left join ga_attribution using (shop_subdomain) + LEFT JOIN app_store_attribution USING (shop_subdomain) + left join segment_attribution using (shop_subdomain) +), + +referrer_mapping as (select * from {{ ref("referrer_mapping") }}), + +final as ( + select + combined_attribution.* EXCLUDE (unified_traffic_source, unified_traffic_medium), + + {# Referrer Mapping #} + lower( + COALESCE( + referrer_mapping.source, + IFF( + (unified_traffic_source IS NULL AND unified_referrer_host ILIKE '%shopify%') + OR + unified_traffic_source ILIKE '%shopify%', + 'Shopify', + unified_traffic_source ) - ) as last_touch_medium, - initcap( - coalesce(first_touch_referrer_mapping.source, first_touch_source) - ) as first_touch_source, - initcap( - coalesce(last_touch_referrer_mapping.source, last_touch_source) - ) as last_touch_source, - initcap( - nullif( - ( - coalesce( - first_touch_referrer_mapping.source, first_touch_source - ) - || ' - ' - || coalesce( - last_touch_referrer_mapping.medium, first_touch_medium - ) - ), - ' - ' - ) - ) as first_touch_source_medium, - initcap( - nullif( - ( - coalesce(first_touch_referrer_mapping.source, last_touch_source) - || ' - ' - || coalesce( - last_touch_referrer_mapping.medium, last_touch_medium - ) - ), - ' - ' + ) + ) AS unified_traffic_source, + lower( + COALESCE( + referrer_mapping.medium, + IFF( + (unified_traffic_medium IS NULL AND unified_referrer_host ILIKE '%shopify%') + OR + unified_traffic_medium ILIKE '%shopify%', + 'App Store', + unified_traffic_medium ) - ) as last_touch_source_medium, - coalesce( - acquisition_first_page_path ilike '%/blog/%', false - ) as is_blog_referral, - timediff( - 'days', first_touch_at_pt, first_installed_at_pt - ) as days_to_install, - coalesce( - first_touch_app_store_surface_type = true - or last_touch_app_store_surface_type = true, - false - ) as is_app_store_referral, - coalesce( - first_touch_app_store_surface_type = 'search_ad' - or last_touch_app_store_surface_type = 'search_ad', - false - ) as is_app_store_search_ad_referral, - app_store_ad_click_counts.* exclude (shop_subdomain) - from shops - left join combined_attribution using (shop_subdomain) - left join - referrer_mapping as first_touch_referrer_mapping - on combined_attribution.first_touch_referrer_host - = first_touch_referrer_mapping.host - left join - referrer_mapping as last_touch_referrer_mapping - on combined_attribution.last_touch_referrer_host - = last_touch_referrer_mapping.host - left join app_store_ad_click_counts using (shop_subdomain) - ), - - final as ( - - select - *, - coalesce( - app_store_ad_click_app_store_surface_type is not null, false - ) as app_store_has_ad_click, - coalesce( - app_store_organic_click_app_store_surface_type is not null, false - ) as has_app_store_organic_click, - - case - when - app_store_has_ad_click = true and has_app_store_organic_click = true - then 'app_store_ad_click_and_organic_click' - when app_store_has_ad_click = true - then 'app_store_ad_click' - when has_app_store_organic_click = true - then 'app_store_organic_click' - else '(direct or predates tracking)' - end as app_store_click_type - from combined - left join app_store_ad_clicks using (shop_subdomain) - left join app_store_install_events using (shop_subdomain) - left join app_store_organic_clicks using (shop_subdomain) - ) - -select * -from final + ) + ) AS unified_traffic_medium, + + {# Referral Type #} + coalesce( + unified_traffic_path ilike '%blog%', FALSE + ) as is_blog_referral, + timediff( + 'days', unified_first_touch_at_pt, first_installed_at_pt + ) as days_to_install, + coalesce( + unified_app_store_surface_type ilike '%search_ad%', + FALSE + ) as is_app_store_search_ad_referral, + referrer_mapping.medium as referrer_medium, + referrer_mapping.source as referrer_source + from shops + left join combined_attribution using (shop_subdomain) + left join + referrer_mapping + on + LOWER(REPLACE(combined_attribution.unified_traffic_source, 'www.', '')) + = lower(referrer_mapping.host) + OR + lower(REPLACE(combined_attribution.unified_referrer_host, 'www.', '')) + = lower(referrer_mapping.host) +) + +select * from final diff --git a/models/mesa/intermediate/int_simplified_shop_attribution.sql b/models/mesa/intermediate/int_simplified_shop_attribution.sql new file mode 100644 index 0000000..4656174 --- /dev/null +++ b/models/mesa/intermediate/int_simplified_shop_attribution.sql @@ -0,0 +1,22 @@ +with unified_columns AS ( + {% set excluded_prefixes = ['ga_', 'segment_', 'mesa_install_', 'app_store_'] %} + {% set table_name = ref("int_shop_install_sources") %} + {% set column_names = dbt_utils.get_filtered_columns_in_relation(table_name, except=['shop_subdomain']) %} + {# {{ log("Debug: column_names = " ~ column_names, info=True) }} #} + SELECT + shop_subdomain, + {% for column_name in column_names %} + {% set column_name = column_name|lower %} + {% set result = [] %} + {{ should_exclude_column_by_prefix(column_name, excluded_prefixes, result) }} + {% if result|length == 0 %} + {{ column_name }} AS acq_{{ column_name }} + {%- if not loop.last %},{% endif %} + {% endif %} + {% endfor %} + FROM {{ table_name }} +) + +SELECT + unified_columns.* +FROM unified_columns diff --git a/models/mesa/marts/_shops.yml b/models/mesa/marts/_shops.yml index b5bfdd5..4c3e71d 100644 --- a/models/mesa/marts/_shops.yml +++ b/models/mesa/marts/_shops.yml @@ -1,1138 +1,733 @@ +--- version: 2 models: - name: shops description: formatted, production-ready shops. meta: - metabase.caveats: - this table combines all the install records of `m3_mesa` into - one shop record. + metabase.caveats: this table combines all the install records of `m3_mesa` into one shop record. tests: - dbt_expectations.expect_table_row_count_to_be_between: min_value: 4000 columns: - - name: shop_subdomain + - description: The foreign key for the Shop. + name: shop_subdomain tests: - not_null - unique - description: The foreign key of the Shop. - - name: first_installed_at_pt - tests: - - not_null - description: The effective created at for the shop. - - name: currency - tests: - - not_null - description: The financial currency used by the shop with its customers. - - name: unique_workflows_successfully_run_count - tests: - - not_null - description: The number of workflow runs that have completed without error. - - name: shopify_plan_name - description: The shopify plan used by the shop. - - name: install_status - description: The current mesa app installation status of the shop. - - name: status - description: The usage status of the shop. - - name: referral - description: "[fill]" - - name: meta - description: a field used by account services to record onboarding sessions. - - name: latest_installed_at_pt - description: The most recent app installation date. - - name: billing_method_name - description: The method used to charge the shop for their subscription & usage. - - name: daily_plan_revenue - description: The amount of revenue from plan charges for this day. - - name: price_per_action - description: "[fill]" - - name: activation_date_pt - description: The date the shop achieved the current definition of activated. - - name: is_activated - description: whether the shop has achieved activation. - - name: templates_installed_count - description: The number of templates the shop has installed as a workflow. - - name: balance_used - description: "[fill]" - - name: shopify_id - description: The official shopify identifier for the shop. - - name: plan_price - description: The current mesa plan's monthly cost. - - name: plan_used - description: The number of automation runs used in the current billing bucket - - name: percent_complete - description: The percent of the days in the month that have been completed - - name: billing_on_pt - description: "From Shopify: The date this billing period will rollover" - - name: plan_name - description: The mesa plan the shop is currently subscribed to. - - name: percent_used - description: The perecent of automtions used in the current billing bucket. - - name: balance_remaining - description: "From: Shopify: The dollars reminaing in this billing cycle's hard_limit" - - name: shopify_shop_gmv_initial_total_usd - description: The 30-day gmv of the shop at the time of installation. + - description: The effective created at for the shop. + name: first_installed_at_pt + tests: + - not_null + - description: The financial currency used by the shop with its customers. + name: currency + tests: + - not_null + - description: The number of workflow runs that have completed without error. + name: unique_workflows_successfully_run_count + tests: + - not_null + - description: The shopify plan used by the shop. + name: shopify_plan_name + - description: The current mesa app installation status of the shop. + name: install_status + - description: The usage status of the shop. + name: status + - description: "[fill]" + name: referral + - description: a field used by account services to record onboarding sessions. + name: meta + - description: The most recent app installation date. + name: latest_installed_at_pt + - description: The method used to charge the shop for their subscription & usage. + name: billing_method_name + - description: The amount of revenue from plan charges for this day. + name: daily_plan_revenue + - description: "[fill]" + name: price_per_action + - description: The date the shop achieved the current definition of activated. + name: activation_date_pt + - description: whether the shop has achieved activation. + name: is_activated + - description: The number of templates the shop has installed as a workflow. + name: templates_installed_count + - description: "[fill]" + name: balance_used + - description: The official shopify identifier for the shop. + name: shopify_id + - description: The current mesa plan's monthly cost. + name: plan_price + - description: The number of automation runs used in the current billing bucket + name: plan_used + - description: The percent of the days in the month that have been completed + name: percent_complete + - description: "From Shopify: The date this billing period will rollover" + name: billing_on_pt + - description: The mesa plan the shop is currently subscribed to. + name: plan_name + - description: The perecent of automtions used in the current billing bucket. + name: percent_used + - description: "From: Shopify: The dollars reminaing in this billing cycle's hard_limit" + name: balance_remaining + - description: The 30-day gmv of the shop at the time of installation. meta: - metabase.semantic_type: type/Currency metabase.display_name: initial revenue / gmv - - name: trial_ends_pt - description: The date the initial billing trial period ends. + metabase.semantic_type: type/Currency + name: shopify_shop_gmv_initial_total_usd + - description: The date the initial billing trial period ends. meta: metabase.display_name: Trial End Date (PT) - - name: chargebee_id - description: The id of the chargebee account if used for billing. - - name: billing_updated_at_pt - description: The timestamp the billing information was updated at in pt. + name: trial_ends_pt + - description: The id of the chargebee account if used for billing. + name: chargebee_id + - description: The timestamp the billing information was updated at in pt. meta: metabase.display_name: Billing Updated At (PT) - - name: plan_type - description: "[fill]" - - name: days_complete - description: "[fill]" - - name: plan_id - description: The code-friendly shortcode of the current mesa plan. + name: billing_updated_at_pt + - description: "[fill]" + name: plan_type + - description: "[fill]" + name: days_complete + - description: The code-friendly shortcode of the current mesa plan. meta: metabase.display_name: Plan Identifier - - name: shopify_shop_gmv_current_total_usd - description: The current 30-day GMV of the Shopify Shop. + name: plan_id + - description: The current 30-day GMV of the Shopify Shop. meta: metabase.display_name: Current Shop Revenue / GMV metabase.semantic_type: type/Currency - - name: plan_interval - description: The frequency of the billing plan interval. - - name: trial_days - description: The initial length of the trial period. - - name: is_builder_wizard_completed - description: "[fill]" - - name: hotjar_url - description: a direct link to the user's hotjar sessions. - - name: backdoor_url - description: a direct link to the Shop's backdoor ui. - - name: minutes_using_app - description: - The total minutes between the first and last pageview inside the - app. + name: shopify_shop_gmv_current_total_usd + - description: The frequency of the billing plan interval. + name: plan_interval + - description: The initial length of the trial period. + name: trial_days + - description: "[fill]" + name: is_builder_wizard_completed + - description: a direct link to the user's hotjar sessions. + name: hotjar_url + - description: a direct link to the Shop's backdoor ui. + name: backdoor_url + - description: The total minutes between the first and last pageview inside the app. + name: minutes_using_app tests: - dbt_utils.not_null_proportion: at_least: 0.7 config: where: first_installed_at_pt > '2020-12-18' - - name: workflow_runs_attempted_count - description: The number of Workflow Run attempts that have been started. + - description: The number of Workflow Run attempts that have been started. + name: workflow_runs_attempted_count tests: - not_null - - name: last_seen_in_app_at_pt - description: The timestamp of the last pageview inside the pap. + - description: The timestamp of the last pageview inside the pap. + name: last_seen_in_app_at_pt tests: - dbt_utils.not_null_proportion: at_least: 0.7 - - name: workflow_run_success_count - description: The number of Workflow Run attempts that have completed successfully. + - description: The number of Workflow Run attempts that have completed successfully. + name: workflow_run_success_count tests: - not_null - - name: minutes_until_uninstall - description: The minutes between initial install and the latest uninstall. - - name: first_seen_in_app_at_pt - description: The timestamp of the first pageview within the app. + - description: The minutes between initial install and the latest uninstall. + name: minutes_until_uninstall + - description: The timestamp of the first pageview within the app. + name: first_seen_in_app_at_pt tests: - dbt_utils.not_null_proportion: at_least: 0.7 - - name: workflow_run_success_rolling_thirty_day_count - description: - The number of successful workflow run attempts initiated in the last - 30 days as of this day. + - description: The number of successful workflow run attempts initiated in the last 30 days as of this day. + name: workflow_run_success_rolling_thirty_day_count tests: - not_null - - name: days_to_activation - description: The number of days from first install to activation. + - description: The number of days from first install to activation. + name: days_to_activation tests: - dbt_utils.not_null_proportion: at_least: 0.02 - - name: workflow_run_success_rolling_year_count - description: - The number of successful workflow run attempts initiated in the last - year as of this day. - - name: uninstalled_at_pt - description: The timestamp of the latest uninstallation of the app. - - name: first_plan_upgrade_date - description: The date of the first plan upgrade action. - - name: acq_first_touch_campaign - description: The campaign that the shop was acquired through. - - name: acq_first_touch_content - description: The content that the shop was acquired through. - - name: acq_acquisition_first_page_path - description: The first page path that the shop was acquired through. - - name: acq_first_touch_referrer - description: The referrer URL that referred the Shop's first visit. - - name: acq_first_touch_referrer_host - description: The referrer host that referrered the shop's first visit. - - name: acq_first_touch_medium - description: The medium that the shop was acquired through. - - name: acq_first_touch_source - description: The source that the shop was acquired through. - - name: acq_first_touch_source_medium - description: The source & medium that drove the Shop's first visit. - - name: funnel_phase - description: The top-level step in the funnel that the shop is currently in. - tests: - - not_null - - name: has_a_workflow - description: whether the shop has ever created a workflow or installed a template. + - description: The number of successful workflow run attempts initiated in the last year as of this day. + name: workflow_run_success_rolling_year_count + - description: The timestamp of the latest uninstallation of the app. + name: uninstalled_at_pt + - description: The date of the first plan upgrade action. + name: first_plan_upgrade_date + - description: The top-level step in the funnel that the shop is currently in. + name: funnel_phase tests: - not_null - - name: max_funnel_step_achieved_at_pt - description: The timestamp of the latest funnel step achieved in pt. + - description: whether the shop has ever created a workflow or installed a template. + name: has_a_workflow tests: - not_null - - name: has_enabled_a_workflow - description: whether the shop has ever enabled a workflow. + - description: The timestamp of the latest funnel step achieved in pt. + name: max_funnel_step_achieved_at_pt tests: - not_null - - name: cohort_week - description: The week of the Shop's first app installation. + - description: whether the shop has ever enabled a workflow. + name: has_enabled_a_workflow tests: - not_null - - name: max_funnel_step - description: The numeric value of latest funnel step achieved. + - description: The week of the Shop's first app installation. + name: cohort_week tests: - not_null - - name: max_funnel_step_name - description: The name of the latest funnel step achieved. + - description: The numeric value of latest funnel step achieved. + name: max_funnel_step tests: - not_null - - name: cohort_month - description: The month of the Shop's first app installation. + - description: The name of the latest funnel step achieved. + name: max_funnel_step_name tests: - not_null - - name: total_ltv_revenue - description: - The total revenue generated by users who first installed in the given - week. + - description: The month of the Shop's first app installation. + name: cohort_month tests: - not_null + - description: The total revenue generated by users who first installed in the given week. meta: metabase.display_name: Total LTV Revenue metabase.semantic_type: type/Currency - - name: workflows_enabled_current_count - description: The number of currently enabled workflows for the shop. + name: total_ltv_revenue + tests: + - not_null + - description: The number of currently enabled workflows for the shop. + name: workflows_enabled_current_count tests: - not_null - - name: workflows_current_count - description: - The number of total workflows currently created on the shop (enabled - or disabled). + - description: The number of total workflows currently created on the shop (enabled or disabled). + name: workflows_current_count tests: - not_null - - name: trial_end_dt_utc - description: The date the Shop's trial ended. + - description: The date the Shop's trial ended. meta: metabase.display_name: Trial End Date (UTC) - - name: launch_session_date - description: The date of the launch session with customer success. - - name: days_from_launch_session_to_activation - description: The number of days from launch to activation. (may be negative.) + name: trial_end_dt_utc + - description: The date of the launch session with customer success. + name: launch_session_date + - description: The number of days from launch to activation. (may be negative.) meta: - metabase.caveats: - this number may be negative if they activated before the launch - session. - - name: has_had_launch_session - description: whether the shop has had a launch session with customer success. + metabase.caveats: this number may be negative if they activated before the launch session. + name: days_from_launch_session_to_activation + - description: whether the shop has had a launch session with customer success. + name: has_had_launch_session tests: - not_null - - name: shopify_shop_gmv_current_total_tier - description: The tier of the Shop's current revenue. + - description: The tier of the Shop's current revenue. meta: metabase.display_name: current revenue tier/bucket - - name: has_uploadery - description: whether the shop has an account for this app. + name: shopify_shop_gmv_current_total_tier + - description: whether the shop has an account for this app. + name: has_uploadery tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_tracktor - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_tracktor tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_blogstudio - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_blogstudio tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_kitkarts - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_kitkarts tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_smile - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_smile tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_bouncer - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_bouncer tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_pagestudio - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_pagestudio tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_coin - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_coin tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: has_infinite_options - description: whether the shop has an account for this app. + - description: whether the shop has an account for this app. + name: has_infinite_options tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: acq_acquisition_template - description: - The template the Shop intended to use when they first installed the - app. - - name: acq_is_blog_referral - description: - Whether the Shop was referred/entered the marketing site by a blog - post. - tests: - - not_null - - name: unique_workflows_attempted_count - description: The number of workflow attempts that have been started. - tests: - - not_null - - name: shopify_shop_orders_initial_count - description: The 30-day order count volume at the time of app installation. - - name: age_of_store_at_install_bucket - description: The bucket of the Shop's age at install. - - name: age_of_store_at_install_in_days - description: The age (in days) of the store at the initial install. - - name: shopify_shop_created_at_pt - description: The timestamp of the Shopify Shop's creation. - - name: shopify_shop_orders_current_count - description: The current monthly order volume of the shop. - - name: age_of_store_at_install_in_weeks - description: The age (in weeks) of the store at the initial install. - - name: store_leads_category - description: - The first full category/sub-category group of the Shop pulled in - from Store Leads. + - description: The template the Shop intended to use when they first installed the app. + name: acq_acquisition_template + - description: Whether the Shop was referred/entered the marketing site by a blog post. + name: acq_is_blog_referral + tests: + - not_null + - description: The number of workflow attempts that have been started. + name: unique_workflows_attempted_count + tests: + - not_null + - description: The 30-day order count volume at the time of app installation. + name: shopify_shop_orders_initial_count + - description: The bucket of the Shop's age at install. + name: age_of_store_at_install_bucket + - description: The age (in days) of the store at the initial install. + name: age_of_store_at_install_in_days + - description: The timestamp of the Shopify Shop's creation. + name: shopify_shop_created_at_pt + - description: The current monthly order volume of the shop. + name: shopify_shop_orders_current_count + - description: The age (in weeks) of the store at the initial install. + name: age_of_store_at_install_in_weeks + - description: The first full category/sub-category group of the Shop pulled in from Store Leads. meta: metabase.display_name: Shopify Shop Product Category & Subcategory (Store Leads) - - name: store_leads_top_level_category - description: The first top-level category of the Shop pulled in from Store Leads. + name: store_leads_category + - description: The first top-level category of the Shop pulled in from Store Leads. meta: metabase.display_name: Shopify Shop Product Top-Level Category (Store Leads) - - name: store_leads_features - description: A list of the Shop features pulled in from Store Leads. + name: store_leads_top_level_category + - description: A list of the Shop features pulled in from Store Leads. meta: metabase.display_name: Shopify Shop Features (Store Leads) - - name: store_leads_has_recharge - description: - Indicates whether the Shop has Recharge listed in their Store Leads - features. + name: store_leads_features + - description: Indicates whether the Shop has Recharge listed in their Store Leads features. meta: metabase.display_name: Has Recharge? (Store Leads) - - name: store_leads_platform_rank - description: - The rank of the Shop on the platform (Shopify) pulled in from Store - Leads. + name: store_leads_has_recharge + - description: The rank of the Shop on the platform (Shopify) pulled in from Store Leads. meta: metabase.display_name: Shopify Store Rank (Store Leads) - - name: store_leads_platform_rank_percentile - description: The percentile of the Shop's rank pulled in from Store Leads. + name: store_leads_platform_rank + - description: The percentile of the Shop's rank pulled in from Store Leads. meta: metabase.display_name: Shopify Store Rank Percentile (Store Leads) - - name: store_leads_estimated_monthly_sales - description: The estimated monthly sales pulled in from Store Leads. + name: store_leads_platform_rank_percentile + - description: The estimated monthly sales pulled in from Store Leads. meta: - metabase.semantic_type: type/Currency metabase.display_name: Estimated Shop Sales (Store Leads) - - name: store_leads_monthly_app_spend - description: - "The estimated amount the Shop spends on Shopify apps (pulled in\ - \ from Store Leads).\u2020\u2264" - meta: metabase.semantic_type: type/Currency + name: store_leads_estimated_monthly_sales + - description: The estimated amount the Shop spends on Shopify apps (pulled in from Store Leads).†≤ + meta: metabase.display_name: Monthly App Spend (Store Leads) - - name: shopify_shop_country - description: The country of the Shop provided by the Shopify API. - - name: store_leads_estimated_monthly_sales_bucket - description: - The bucket of the Shop's estimated monthly sales pulled in from Store - Leads. + metabase.semantic_type: type/Currency + name: store_leads_monthly_app_spend + - description: The country of the Shop provided by the Shopify API. + name: shopify_shop_country + - description: The bucket of the Shop's estimated monthly sales pulled in from Store Leads. meta: metabase.display_name: Estimated Monthly Sales Bucket (Store Leads) - - name: income_rolling_thirty_day_total - description: - The ShopPad revenue attributed to the Shop from Mesa in the last - 30 days. + name: store_leads_estimated_monthly_sales_bucket + - description: The ShopPad revenue attributed to the Shop from Mesa in the last 30 days. meta: - metabase.semantic_type: type/Currency metabase.display_name: Last 30-Day Income - - name: income_rolling_year_total - description: - The ShopPad revenue attributed to the Shop from Mesa in the last - year. - meta: metabase.semantic_type: type/Currency + name: income_rolling_thirty_day_total + - description: The ShopPad revenue attributed to the Shop from Mesa in the last year. + meta: metabase.display_name: Last Year Income - - name: is_custom_app - description: - Whether the Shop is a custom application with custom pricing not - billed through the Shopify system. + metabase.semantic_type: type/Currency + name: income_rolling_year_total + - description: Whether the Shop is a custom application with custom pricing not billed through the Shopify system. + name: is_custom_app tests: - not_null - - name: shopify_shop_gmv_initial_cohort_avg_percent - description: - The percent comparison of the Shop's initial revenue compared to - its cohort. + - description: The percent comparison of the Shop's initial revenue compared to its cohort. meta: metabase.display_name: Shopify Shop GMV Compared to Cohort Avg (Install) - - name: shopify_shop_gmv_current_cohort_avg_percent - description: - The percent comparison of the Shop's current revenue compared to - all other Shops. + name: shopify_shop_gmv_initial_cohort_avg_percent + - description: The percent comparison of the Shop's current revenue compared to all other Shops. meta: metabase.display_name: Shopify Shop GMV Compared to All Avg (Current) - - name: latest_installed_at_utc - description: The timestamp of the Shop's latest install in UTC. - - name: first_installed_at_utc - description: The timestamp of the Shop's first install in UTC. - - name: is_mql - description: Whether the Shop is an MQL. + name: shopify_shop_gmv_current_cohort_avg_percent + - description: The timestamp of the Shop's latest install in UTC. + name: latest_installed_at_utc + - description: The timestamp of the Shop's first install in UTC. + name: first_installed_at_utc + - description: Whether the Shop is an MQL. meta: metabase.display_name: Is MQL? - - name: initial_shopify_plan_name - description: The name of the Shop's initial Shopify plan. - - name: first_installed_on_pt - description: The date of the Shop's first install. + name: is_mql + - description: The name of the Shop's initial Shopify plan. + name: initial_shopify_plan_name + - description: The date of the Shop's first install. meta: metabase.display_name: First Installed On (PT) - - name: last_broadcast_email_open_at_pt - description: The timestamp of the Shop's last broadcast email open - - name: broadcast_email_opens_count - description: The number of broadcast email opens for the Shop. - - name: has_opened_broadcast_email - description: Whether the Shop has opened a Broadcast email. - - name: first_broadcast_email_open_at_pt - description: The timestamp of the Shop's first email open. - - name: first_broadcast_email_clicked_at_pt - description: The timestamp of the Shop's first broadcast email click. - - name: first_broadcast_email_converted_at_pt - description: The timestamp of the Shop's first broadcast email conversion. - - name: last_broadcast_email_clicked_at_pt - description: The timestamp of the Shop's last broadcast email click. - - name: broadcast_email_click_count - description: The number of Broadcast email clicks for the Shop. - - name: broadcast_email_conversion_count - description: The number of email conversions for the Shop. - - name: has_clicked_broadcast_email - description: Whether the Shop has clicked a broadcast email. - - name: last_broadcast_email_converted_at_pt - description: The timestamp of the Shop's last broadcast email conversion. - - name: first_in_constellation_at_utc - description: The timestamp of the Shop's first install in the constellation. - - name: first_in_constellation_on_pt - description: - The date of the Shop's first install in the constellation apart from - MESA. + name: first_installed_on_pt + - description: The timestamp of the Shop's last broadcast email open + name: last_broadcast_email_open_at_pt + - description: The number of broadcast email opens for the Shop. + name: broadcast_email_opens_count + - description: Whether the Shop has opened a Broadcast email. + name: has_opened_broadcast_email + - description: The timestamp of the Shop's first email open. + name: first_broadcast_email_open_at_pt + - description: The timestamp of the Shop's first broadcast email click. + name: first_broadcast_email_clicked_at_pt + - description: The timestamp of the Shop's first broadcast email conversion. + name: first_broadcast_email_converted_at_pt + - description: The timestamp of the Shop's last broadcast email click. + name: last_broadcast_email_clicked_at_pt + - description: The number of Broadcast email clicks for the Shop. + name: broadcast_email_click_count + - description: The number of email conversions for the Shop. + name: broadcast_email_conversion_count + - description: Whether the Shop has clicked a broadcast email. + name: has_clicked_broadcast_email + - description: The timestamp of the Shop's last broadcast email conversion. + name: last_broadcast_email_converted_at_pt + - description: The timestamp of the Shop's first install in the constellation. + name: first_in_constellation_at_utc + - description: The date of the Shop's first install in the constellation apart from MESA. meta: metabase.display_name: First In Constellation On (PT) - - name: first_in_constellation_at_pt - description: - The timestamp of the Shop's first install in the constellation apart - from MESA. + name: first_in_constellation_on_pt + - description: The timestamp of the Shop's first install in the constellation apart from MESA. meta: metabase.display_name: First In Constellation At (PT) - - name: constellation_cohort_week - description: - The week of the Shop's first install in the constellation apart from - MESA. + name: first_in_constellation_at_pt + - description: The week of the Shop's first install in the constellation apart from MESA. meta: metabase.display_name: Constellation Cohort Week - - name: last_journey_email_converted_at_pt - description: The timestamp of the Shop's last journey email conversion. - - name: has_converted_via_broadcast_email - description: Whether the Shop has converted via broadcast email. - - name: journey_email_opens_count - description: The number of journey email opens for the Shop. - - name: first_journey_email_converted_at_pt - description: The timestamp of the Shop's first journey email conversion. - - name: has_converted_via_journey_email - description: Whether the Shop has converted via journey email. - - name: journey_email_conversion_count - description: The number of journey email conversions for the Shop. - - name: last_journey_email_clicked_at_pt - description: The timestamp of the Shop's last journey email click. - - name: last_journey_email_open_at_pt - description: The timestamp of the Shop's last journey email open. - - name: first_journey_email_clicked_at_pt - description: The timestamp of the Shop's first journey email click. - - name: journey_email_click_count - description: The number of journey email clicks for the Shop. - - name: has_clicked_journey_email - description: Whether the Shop has clicked a journey email. - - name: first_journey_email_open_at_pt - description: The timestamp of the Shop's first journey email open. - - name: has_opened_journey_email - description: Whether the Shop has opened a journey email. - - name: is_in_trial - description: Whether the Shop is in a trial. + name: constellation_cohort_week + - description: The timestamp of the Shop's last journey email conversion. + name: last_journey_email_converted_at_pt + - description: Whether the Shop has converted via broadcast email. + name: has_converted_via_broadcast_email + - description: The number of journey email opens for the Shop. + name: journey_email_opens_count + - description: The timestamp of the Shop's first journey email conversion. + name: first_journey_email_converted_at_pt + - description: Whether the Shop has converted via journey email. + name: has_converted_via_journey_email + - description: The number of journey email conversions for the Shop. + name: journey_email_conversion_count + - description: The timestamp of the Shop's last journey email click. + name: last_journey_email_clicked_at_pt + - description: The timestamp of the Shop's last journey email open. + name: last_journey_email_open_at_pt + - description: The timestamp of the Shop's first journey email click. + name: first_journey_email_clicked_at_pt + - description: The number of journey email clicks for the Shop. + name: journey_email_click_count + - description: Whether the Shop has clicked a journey email. + name: has_clicked_journey_email + - description: The timestamp of the Shop's first journey email open. + name: first_journey_email_open_at_pt + - description: Whether the Shop has opened a journey email. + name: has_opened_journey_email + - description: Whether the Shop is in a trial. meta: metabase.display_name: Is In Trial? + name: is_in_trial tests: - not_null - - name: has_ever_upgraded_to_paid_plan - description: Whether the Shop has ever upgraded to a paid plan. + - description: Whether the Shop has ever upgraded to a paid plan. meta: metabase.display_name: Ever Upgraded to Paid Plan? + name: has_ever_upgraded_to_paid_plan tests: - not_null - - name: first_plan_identifier - description: The identifier of the Shop's first plan. - - name: days_until_first_plan_upgrade - description: The number of days until the Shop's first plan upgrade. + - description: The identifier of the Shop's first plan. + name: first_plan_identifier + - description: The number of days until the Shop's first plan upgrade. meta: metabase.display_name: Days Until First Plan Upgrade - - name: is_currently_paying - description: Whether the Shop is currently paying for a plan. + name: days_until_first_plan_upgrade + - description: Whether the Shop is currently paying for a plan. meta: metabase.display_name: Is Currently Paying? + name: is_currently_paying tests: - not_null - dbt_expectations.expect_column_distinct_count_to_equal: value: 2 - - name: currency_not_supported - description: - Whether the Shop's currency is not supported in the DBT/Snowflake - currency conversion data. + - description: Whether the Shop's currency is not supported in the DBT/Snowflake currency conversion data. meta: metabase.display_name: Currency Not Supported? + name: currency_not_supported tests: - not_null - - name: is_shopify_zombie_plan - description: - Indicates whether the store is on a 'frozen', 'fraudulent', 'paused', - 'dormant' or 'cancelled' Shopify plan. TRUE means they are, FALSE means they - are not. + - description: Indicates whether the store is on a 'frozen', 'fraudulent', 'paused', 'dormant' or 'cancelled' Shopify plan. TRUE means they are, FALSE means they are not. meta: metabase.display_name: Is Zombie Shopify Plan? - tests: - - not_null - - name: workflow_run_attempt_rolling_year_count - description: - The number of successful workflow run attempts initiated in the last - year as of this day. - - name: average_daily_usage_revenue - description: - The average daily usage revenue for the Shop (calculated by the average - of the last 30 billable days). - - name: workflow_run_attempt_rolling_thirty_day_count - description: - The number of successful workflow run attempts initiated in the last - 30 days as of this day. - - name: input_step_rolling_thirty_day_count - description: - The total number of Workflow Steps started in the last 30 days as - of Yesterday. - tests: - - not_null - - name: output_step_rolling_thirty_day_count - description: - The total number of "input" (Trigge) Workflow Steps completed in - the last 30 days as of Yesterday. - tests: - - not_null - - name: total_workflow_steps_rolling_thirty_day_count - description: - The total number of Workflow Steps completed in the last 30 days - as of Yesterday. - tests: - - not_null - - name: first_workflow_trigger_key - description: - The key of the first step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: total_thirty_day_revenue - description: The total revenue for the Shop in the last 30 days as of Yesterday. - tests: - - not_null - - name: first_workflow_trigger_app - description: - The app of the first step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: first_workflow_destination_key - description: - The key of the last step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: first_workflow_destination_app - description: - The app of the last step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: first_workflow_destination_name - description: - The name of the last step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: average_daily_revenue - description: - The average daily revenue for the Shop (calculated by the average - of the last 30 billable days). - - name: first_workflow_trigger_name - description: - The name of the first step in the Shop's first workflow. Gives a - clue to their MESA use case. - - name: integration_apps_enabled_count - description: The number of unique integration apps enabled for the Shop. - tests: - - not_null - - name: pro_apps_enabled_count - description: The number of unique pro apps enabled in workflows for the Shop. - tests: - - not_null - - name: first_workflow_sort_title - description: - The sort title of the first workflow in the Shop. (Cleaned title - or marked as DELETED.) - - name: first_workflow_trigger_destination_app_pair - description: - The app pair of the Shop's first workflow. Gives a clue to their - MESA use case. - - name: first_workflow_trigger_destination_key_pair - description: - The key pair of the Shop's first workflow. Gives a clue to their - MESA use case. - - name: first_workflow_destination_name - description: - The name of the last step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: first_workflow_trigger_name - description: - The name of the first step in the Shop's first workflow. Gives a - clue to their MESA use case. - - name: max_workflow_steps - description: The maximum number of steps in any workflow for the Shop. - tests: - - not_null - - name: first_workflow_title - description: - The title of the Shop's first workflow. Gives a clue to their MESA - use case. - - name: is_using_pro_apps - description: Whether the Shop is using any pro apps. - tests: - - not_null - - name: first_workflow_trigger_key - description: - The key of the first step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: first_workflow_destination_app - description: - The app of the last step in the Shop's first workflow. Gives a clue - to their MESA use case. - - name: first_workflow_trigger_destination_name_pair - description: - The name pair of the Shop's first workflow. Gives a clue to their - MESA use case. - - name: first_workflow_app_chain - description: - The app chain of the Shop's first workflow. Gives a clue to their - MESA use case. - - name: first_workflow_step_chain - description: - The step chain of the Shop's first workflow. Gives a clue to their - MESA use case. - - name: first_workflow_id - description: - The ID of the Shop's first workflow. Gives a clue to their MESA use - case. - - name: has_ever_installed_coin - description: Whether the Shop has ever installed Coin. - - name: has_shoppad_constellation_app - description: Whether the Shop has ever installed any Shoppad Constellation app. - - name: plan_change_count - description: The number of times the Shop has changed plans. - tests: - - not_null - - name: has_ever_installed_infinite_options - description: Whether the Shop has ever installed Infinite Options. - - name: plan_change_chain - description: The plan change chain of the Shop. - - name: has_ever_installed_kitkarts - description: Whether the Shop has ever installed Kit Karts. - - name: has_ever_installed_smile - description: Whether the Shop has ever installed Smile. - - name: has_ever_installed_bouncer - description: Whether the Shop has ever installed Bouncer. - - name: has_ever_installed_tracktor - description: Whether the Shop has ever installed Tracktor. - - name: has_ever_installed_pagestudio - description: Whether the Shop has ever installed Page Studio. - - name: has_ever_installed_blogstudio - description: Whether the Shop has ever installed Blog Studio. - - name: did_install_another_shoppad_app_first - description: - Whether the Shop installed another Shoppad app before installing - their first Shoppad Constellation app. - - name: has_ever_installed_uploadery - description: Whether the Shop has ever installed Uploadery. - - name: first_shoppad_app_installed - description: The first Shoppad app installed by the Shop. - - name: did_pay_and_then_downgrade_to_free - description: - Whether the Shop has ever paid for a plan and then downgraded to - the free plan. - - name: virtual_plan - description: The v10 plan the Shop's usage qualifies for. - tests: - - not_null - - name: virtual_plan_workflow_run_attempt_qualifier - description: - The qualifier for the Shop's virtual plan based on their workflow - run attempts/triggers. - - name: virtual_plan_pro_app_qualifier - description: - The qualifier for the Shop's virtual plan based on their pro app - usage. - - name: virtual_plan_step_qualifier - description: - The qualifier for the Shop's virtual plan based on their workflow - step usage. - - name: workflow_runs_stop_count - description: The number of workflow runs that have resulted in Stop. - tests: - - not_null - - name: is_likely_shopify_plus_dev_store - description: - Whether the Shop is likely a Shopify Plus dev store and therefore - not valuable. - - name: workflow_run_failure_rolling_year_count - description: - The number of workflow runs that have resulted in Failure in the - last year. - - name: workflow_run_stop_rolling_year_count - description: - The number of workflow runs that have resulted in Stop in the last - year. - - name: workflow_run_stop_rolling_thirty_day_count - description: - The number of workflow runs that have resulted in Stop in the last - 30 days. - - name: workflow_runs_fail_count - description: The number of workflow runs that have resulted in Failure. - - name: workflow_run_failure_rolling_thirty_day_count - description: - The number of workflow runs that have resulted in Failure in the - last 30 days. - - name: email_unsubscribe_email_name - description: The name of the email the Shop unsubscribed from. - - name: first_shoppad_app_installed_at_pt - description: The date/time the Shop installed their first Shoppad app. - - name: is_email_acquisition - description: - Whether the Shop was acquired via email/email played a role in their - journey. - - name: has_unsubscribed_from_email - description: Whether the Shop has unsubscribed from email. - - name: first_shoppad_app_installed_at_utc - description: The date/time the Shop installed their first Shoppad app in UTC. - - name: projected_mrr - description: Their daily average MRR multiplied by 30. - tests: - - not_null - - name: first_newsletter_sent_on_pt - description: The date the Shop received their first newsletter. - - name: email_unsubscribe_email_type - description: The type of email the Shop unsubscribed from. - - name: first_newsletter_sent_at_pt - description: The date/time the Shop received their first newsletter. - - name: first_journey_sent_on_pt - description: The date the Shop received their first journey email. - - name: first_journey_sent_at_pt - description: The date/time the Shop received their first journey email. - - name: has_churned - description: Whether the Shop has churned. - - name: first_trial_plan_identifier - description: The identifier of the Shop's first trial plan. - - name: plan_upgrade_funnel_status - description: - The status of the Shop's plan upgrade funnel through trial, paying - and churn. - - name: first_journey_sent_name - description: The name of the first journey email the Shop received. - - name: first_journey_sent_subject - description: The subject of the first journey email the Shop received. - - name: trial_days_completed - description: The number of days the Shop has been in trial. - - name: has_contacted_support - description: Whether the Shop has contacted support. - - name: first_newsletter_sent_subject - description: The subject of the first newsletter the Shop received. - - name: first_newsletter_sent_name - description: The name of the first newsletter the Shop received. - - name: has_done_a_trial - description: Whether the Shop has ever been in trial. - - name: first_trial_start_date - description: The date the Shop started their first trial. - - name: paid_days_completed - description: The number of days the Shop has been on a paid plan. - - name: support_lastreplyat - description: The timestamp of the Shop's last support reply. - - name: days_until_first_trial - description: The number of days until the Shop's first trial. - - name: churned_customer_duration_in_days - description: The number of days the Shop has been on a paid plan. - - name: churned_on_pt - description: The date the Shop churned. - - name: churned_customer_duration_in_weeks - description: The number of weeks the Shop has been/was on a paid plan. - - name: churned_customer_duration_in_months - description: The number of months the Shop has been on a paid plan. - - name: has_saved_a_workflow - description: Whether the Shop has ever saved a workflow. - tests: - - not_null - - name: max_workflow_steps_with_deleted - description: - The maximum number of steps in any workflow for the Shop, including - deleted steps. - tests: - - not_null - - name: has_successfully_run_a_test - description: Whether the Shop has ever successfully run a test. - tests: - - not_null - - name: billing_overage_last_count - description: The number of times the Shop has been over their billing limit. - - name: overlimit_date_pt - description: The date the Shop went over their billing limit. - - name: has_attempted_a_test - description: Whether the Shop has ever attempted to run a test. - tests: - - not_null - - name: yesterdays_inc_amount - description: The Shop's income amount from yesterday. - tests: - - not_null - - name: analytics_currency - description: The currency of the Shop's analytics. - - name: is_pql - description: Whether the Shop is a PQL. + name: is_shopify_zombie_plan + tests: + - not_null + - description: The number of successful workflow run attempts initiated in the last year as of this day. + name: workflow_run_attempt_rolling_year_count + - description: The average daily usage revenue for the Shop (calculated by the average of the last 30 billable days). + name: average_daily_usage_revenue + - description: The number of successful workflow run attempts initiated in the last 30 days as of this day. + name: workflow_run_attempt_rolling_thirty_day_count + - description: The total number of Workflow Steps started in the last 30 days as of Yesterday. + name: input_step_rolling_thirty_day_count + tests: + - not_null + - description: The total number of "input" (Trigge) Workflow Steps completed in the last 30 days as of Yesterday. + name: output_step_rolling_thirty_day_count + tests: + - not_null + - description: The total number of Workflow Steps completed in the last 30 days as of Yesterday. + name: total_workflow_steps_rolling_thirty_day_count + tests: + - not_null + - description: The key of the first step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_key + - description: The total revenue for the Shop in the last 30 days as of Yesterday. + name: total_thirty_day_revenue + tests: + - not_null + - description: The app of the first step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_app + - description: The key of the last step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_destination_key + - description: The app of the last step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_destination_app + - description: The name of the last step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_destination_name + - description: The average daily revenue for the Shop (calculated by the average of the last 30 billable days). + name: average_daily_revenue + - description: The name of the first step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_name + - description: The number of unique integration apps enabled for the Shop. + name: integration_apps_enabled_count + tests: + - not_null + - description: The number of unique pro apps enabled in workflows for the Shop. + name: pro_apps_enabled_count + tests: + - not_null + - description: The sort title of the first workflow in the Shop. (Cleaned title or marked as DELETED.) + name: first_workflow_sort_title + - description: The app pair of the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_destination_app_pair + - description: The key pair of the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_destination_key_pair + - description: The name of the last step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_destination_name + - description: The name of the first step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_name + - description: The maximum number of steps in any workflow for the Shop. + name: max_workflow_steps + tests: + - not_null + - description: The title of the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_title + - description: Whether the Shop is using any pro apps. + name: is_using_pro_apps + tests: + - not_null + - description: The key of the first step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_key + - description: The app of the last step in the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_destination_app + - description: The name pair of the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_trigger_destination_name_pair + - description: The app chain of the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_app_chain + - description: The step chain of the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_step_chain + - description: The ID of the Shop's first workflow. Gives a clue to their MESA use case. + name: first_workflow_id + - description: Whether the Shop has ever installed Coin. + name: has_ever_installed_coin + - description: Whether the Shop has ever installed any Shoppad Constellation app. + name: has_shoppad_constellation_app + - description: The number of times the Shop has changed plans. + name: plan_change_count + tests: + - not_null + - description: Whether the Shop has ever installed Infinite Options. + name: has_ever_installed_infinite_options + - description: The plan change chain of the Shop. + name: plan_change_chain + - description: Whether the Shop has ever installed Kit Karts. + name: has_ever_installed_kitkarts + - description: Whether the Shop has ever installed Smile. + name: has_ever_installed_smile + - description: Whether the Shop has ever installed Bouncer. + name: has_ever_installed_bouncer + - description: Whether the Shop has ever installed Tracktor. + name: has_ever_installed_tracktor + - description: Whether the Shop has ever installed Page Studio. + name: has_ever_installed_pagestudio + - description: Whether the Shop has ever installed Blog Studio. + name: has_ever_installed_blogstudio + - description: Whether the Shop installed another Shoppad app before installing their first Shoppad Constellation app. + name: did_install_another_shoppad_app_first + - description: Whether the Shop has ever installed Uploadery. + name: has_ever_installed_uploadery + - description: The first Shoppad app installed by the Shop. + name: first_shoppad_app_installed + - description: Whether the Shop has ever paid for a plan and then downgraded to the free plan. + name: did_pay_and_then_downgrade_to_free + - description: The v10 plan the Shop's usage qualifies for. + name: virtual_plan + tests: + - not_null + - description: The qualifier for the Shop's virtual plan based on their workflow run attempts/triggers. + name: virtual_plan_workflow_run_attempt_qualifier + - description: The qualifier for the Shop's virtual plan based on their pro app usage. + name: virtual_plan_pro_app_qualifier + - description: The qualifier for the Shop's virtual plan based on their workflow step usage. + name: virtual_plan_step_qualifier + - description: The number of workflow runs that have resulted in Stop. + name: workflow_runs_stop_count + tests: + - not_null + - description: Whether the Shop is likely a Shopify Plus dev store and therefore not valuable. + name: is_likely_shopify_plus_dev_store + - description: The number of workflow runs that have resulted in Failure in the last year. + name: workflow_run_failure_rolling_year_count + - description: The number of workflow runs that have resulted in Stop in the last year. + name: workflow_run_stop_rolling_year_count + - description: The number of workflow runs that have resulted in Stop in the last 30 days. + name: workflow_run_stop_rolling_thirty_day_count + - description: The number of workflow runs that have resulted in Failure. + name: workflow_runs_fail_count + - description: The number of workflow runs that have resulted in Failure in the last 30 days. + name: workflow_run_failure_rolling_thirty_day_count + - description: The name of the email the Shop unsubscribed from. + name: email_unsubscribe_email_name + - description: The date/time the Shop installed their first Shoppad app. + name: first_shoppad_app_installed_at_pt + - description: Whether the Shop was acquired via email/email played a role in their journey. + name: is_email_acquisition + - description: Whether the Shop has unsubscribed from email. + name: has_unsubscribed_from_email + - description: The date/time the Shop installed their first Shoppad app in UTC. + name: first_shoppad_app_installed_at_utc + - description: Their daily average MRR multiplied by 30. + name: projected_mrr + tests: + - not_null + - description: The date the Shop received their first newsletter. + name: first_newsletter_sent_on_pt + - description: The type of email the Shop unsubscribed from. + name: email_unsubscribe_email_type + - description: The date/time the Shop received their first newsletter. + name: first_newsletter_sent_at_pt + - description: The date the Shop received their first journey email. + name: first_journey_sent_on_pt + - description: The date/time the Shop received their first journey email. + name: first_journey_sent_at_pt + - description: Whether the Shop has churned. + name: has_churned + - description: The identifier of the Shop's first trial plan. + name: first_trial_plan_identifier + - description: The status of the Shop's plan upgrade funnel through trial, paying and churn. + name: plan_upgrade_funnel_status + - description: The name of the first journey email the Shop received. + name: first_journey_sent_name + - description: The subject of the first journey email the Shop received. + name: first_journey_sent_subject + - description: The number of days the Shop has been in trial. + name: trial_days_completed + - description: Whether the Shop has contacted support. + name: has_contacted_support + - description: The subject of the first newsletter the Shop received. + name: first_newsletter_sent_subject + - description: The name of the first newsletter the Shop received. + name: first_newsletter_sent_name + - description: Whether the Shop has ever been in trial. + name: has_done_a_trial + - description: The date the Shop started their first trial. + name: first_trial_start_date + - description: The number of days the Shop has been on a paid plan. + name: paid_days_completed + - description: The timestamp of the Shop's last support reply. + name: support_lastreplyat + - description: The number of days until the Shop's first trial. + name: days_until_first_trial + - description: The number of days the Shop has been on a paid plan. + name: churned_customer_duration_in_days + - description: The date the Shop churned. + name: churned_on_pt + - description: The number of weeks the Shop has been/was on a paid plan. + name: churned_customer_duration_in_weeks + - description: The number of months the Shop has been on a paid plan. + name: churned_customer_duration_in_months + - description: Whether the Shop has ever saved a workflow. + name: has_saved_a_workflow + tests: + - not_null + - description: The maximum number of steps in any workflow for the Shop, including deleted steps. + name: max_workflow_steps_with_deleted + tests: + - not_null + - description: Whether the Shop has ever successfully run a test. + name: has_successfully_run_a_test + tests: + - not_null + - description: The number of times the Shop has been over their billing limit. + name: billing_overage_last_count + - description: The date the Shop went over their billing limit. + name: overlimit_date_pt + - description: Whether the Shop has ever attempted to run a test. + name: has_attempted_a_test + tests: + - not_null + - description: The Shop's income amount from yesterday. + name: yesterdays_inc_amount + tests: + - not_null + - description: The currency of the Shop's analytics. + name: analytics_currency + - description: Whether the Shop is a PQL. + name: is_pql tests: - dbt_utils.not_null_proportion: at_least: 0.9 - - name: apps_used - description: The apps used by the Shop. - - name: apps_used_without_glue - description: - The apps used by the Shop, excluding glue apps such as "filter". - (See project var['glue_apps']) - - name: has_puc_workflow - description: Whether the Shop has a workflow with a PUC step. - tests: - - not_null - - name: source_destination_pairs_list - description: - A list of the Shop's source/destination app pairs from all workflows - (enabled or not). - - name: has_csm_support - description: - Whether the Shop has CSM support and exists in our Book-of-Business - (BOB) + - description: The apps used by the Shop. + name: apps_used + - description: The apps used by the Shop, excluding glue apps such as "filter". (See project var['glue_apps']) + name: apps_used_without_glue + - description: Whether the Shop has a workflow with a PUC step. + name: has_puc_workflow tests: - not_null - - name: acq_last_touch_app_store_surface_type - description: The type of surface for the last touch in the app store. - - name: acq_first_touch_app_store_surface_intra_position - description: The intra position of the first touch on the app store surface. - - name: acq_last_touch_source_medium - description: The source medium of the last touch. - - name: acq_first_touch_app_store_surface_type - description: The type of surface for the first touch in the app store. - - name: acq_last_touch_content - description: The content of the last touch. - - name: acq_first_touch_path - description: The path of the first touch. - - name: acq_mesa_install_event_mesa_source - description: The source of the m3_mesa_install event. - - name: acq_last_touch_url - description: The URL of the last touch. - - name: acq_last_touch_campaign - description: The campaign of the last touch. - - name: acq_first_touch_at_pt - description: The timestamp of the first touch. - - name: acq_last_touch_app_store_surface_intra_position - description: The intra position of the last touch on the app store surface. - - name: acq_last_touch_host - description: The host of the last touch. - - name: acq_last_touch_app_store_surface_detail - description: The surface_detail term of the last touch in the app store. - - name: acq_last_touch_referrer_host - description: The referrer host of the last touch. - - name: acq_last_touch_path - description: The path of the last touch. - - name: acq_is_app_store_search_ad_referral - description: Whether the referral is from an app store search ad. + - description: A list of the Shop's source/destination app pairs from all workflows (enabled or not). + name: source_destination_pairs_list + - description: Whether the Shop has CSM support and exists in our Book-of-Business (BOB) + name: has_csm_support tests: - not_null - - name: acq_first_touch_host - description: The host of the first touch. - - name: acq_install_event_info_source - description: The source of acquisition information. - tests: - - dbt_utils.not_null_proportion: - at_least: 0.95 - config: - where: NOT is_custom_app AND latest_installed_at_pt > '2022-01-01' - - name: acq_last_touch_medium - description: The medium of the last touch. - - name: acq_last_touch_referrer - description: The referrer of the last touch. - - name: acq_first_touch_app_store_locale - description: The locale of the first touch in the app store. - - name: acq_last_touch_at_pt - description: The timestamp of the last touch. - - name: acq_last_touch_app_store_surface_inter_position - description: The inter position of the last touch on the app store surface. - - name: acq_is_app_store_referral - description: Whether the referral is from the app store. - tests: - - not_null - - name: acq_first_touch_url - description: The URL of the first touch. - - name: acq_first_touch_app_store_surface_inter_position - description: The inter position of the first touch on the app store surface. - - name: acq_last_touch_app_store_locale - description: The locale of the last touch in the app store. - - name: acq_last_touch_source - description: The source of the last touch. - - name: acq_app_store_ad_click_utm_medium - description: The utm_medium of the app store ad click. - - name: acq_app_store_ad_click_event_timestamp_pt - description: - The timestamp indicating when the user clicked on an advertisement - in the app store, in the Pacific Time zone. - - name: acq_app_store_organic_click_referrer_host - description: The host URL from which the organic click in the app store originated. - - name: acq_mesa_install_event_referer - description: - The referring URL or source that led to the installation event of - the Mesa application. - - name: acq_has_app_store_organic_click - description: - Indicates whether there was an organic click in the app store related - to the shop or app. - - name: acq_mesa_install_event_utm_source - description: - The UTM source parameter capturing the marketing medium that led - to the Mesa installation event. - - name: acq_app_store_organic_click_app_store_surface_inter_position - description: - The position or location within the app store where the organic click - occurred, for intermediary app store surfaces. - - name: acq_app_store_did_click_ad - description: Indicates whether an ad in the app store was clicked. - - name: acq_app_store_install_event_timestamp_pt - description: - Timestamp marking when the app was installed from the app store, - in Pacific Time. - - name: acq_app_store_install_app_store_surface_detail - description: - Details about the app store surface (section or category) where the - app was installed from. - - name: acq_app_store_ad_click_page_location - description: - The specific page location or section in the app store where the - ad click occurred. - - name: acq_app_store_ad_click_utm_source - description: - The UTM source parameter for tracking the origin of traffic that - led to an ad click in the app store. - - name: acq_app_store_install_utm_term - description: - The UTM term parameter used for identifying specific search terms - leading to an app installation. - - name: acq_app_store_organic_click_app_store_surface_detail - description: - Detailed information about the specific app store surface where an - organic click occurred. - - name: acq_app_store_organic_click_app_store_locale - description: - The locale or regional setting of the app store during an organic - click event. - - name: acq_app_store_ad_click_app_store_locale - description: - The locale or regional setting of the app store during an ad click - event. - - name: acq_mesa_install_event_plan_selected - description: - Details the specific plan or package selected during the Mesa installation - event. - - name: acq_app_store_organic_click_utm_medium - description: - The UTM medium parameter for tracking the type of link or medium - through which the organic click occurred. - - name: acq_app_store_organic_click_utm_campaign - description: - The UTM campaign parameter used for identifying the specific marketing - campaign linked to an organic click. - - name: acq_mesa_install_event_utm_medium - description: - The UTM medium parameter associated with the Mesa installation event - for tracking the marketing channel. - - name: acq_mesa_install_event_utm_campaign - description: - The UTM campaign parameter related to the specific marketing campaign - during the Mesa installation event. - - name: acq_app_store_organic_click_page_location - description: - The specific page location or area in the app store where an organic - click took place. - name: shop_value_per_month - description: The estimated monetary value of the shop on a monthly basis. - - name: acq_mesa_install_event_plan - description: - Identifies the specific Mesa plan or tier chosen during the installation - process. - - name: acq_app_store_ad_click_referrer_host - description: - The host URL or domain that referred the user to the app store ad - click. - - name: acq_app_store_has_ad_click - description: - Indicates whether there was a click on an advertisement within the - app store. - - name: acq_app_store_install_referrer_medium - description: - The medium through which the user was referred to the app store for - installation. - - name: acq_app_store_install_app_store_locale - description: - The locale or regional setting of the app store at the time of the - app installation. - - name: acq_app_store_organic_click_app_store_surface_intra_position - description: - The intra-position or specific subsection within an app store surface - where an organic click occurred. - - name: acq_mesa_install_event_timestamp_pt - description: The Pacific Time timestamp of the Mesa installation event. - - name: acq_app_store_organic_click_app_store_surface_type - description: - The type or category of the app store surface where an organic click - took place. - - name: acq_app_store_install_app_store_surface_type - description: - The type or category of the app store surface from which the app - was installed. - - name: acq_first_touch_app_surface_detail - description: - Details about the first interaction or 'touch' with the app in the - app store, - - name: acq_app_store_ad_click_app_store_surface_inter_position - description: - The inter-position or specific section within an app store surface - where an ad click occurred. - - name: acq_app_store_ad_click_utm_content - description: - The UTM content parameter for tracking the specific content or ad - that was clicked in the app store. - - name: acq_sessions_til_install - description: The number of sessions that occurred before the app was installed. - - name: acq_app_store_install_utm_content - description: - The UTM content parameter for tracking the specific content or ad - that led to an app installation. - - name: acq_app_store_install_utm_source - description: - The UTM source parameter for tracking the origin of traffic that - led to an app installation. - - name: acq_app_store_install_referrer_host - description: - The host URL or domain that referred the user to the app store for - installation. + description: The estimated monetary value of the shop on a monthly basis. Currently plan price. + - description: The timestamp of the last update to the shop in Pacific Time. + name: shopify_last_updated_at_pt + - name: average_plan_revenue + description: The average revenue from the shop's plan. + - name: acq_is_app_store_search_ad_referral + description: Whether the acquisition is a referral from an app store search ad. - name: acq_days_to_install - description: The number of days that passed before the app was installed. - - name: acq_app_store_click_type - description: - The type of click that occurred in the app store, either organic - or ad. - - name: acq_app_store_ad_click_referrer_source - description: The source of the referrer that led to an ad click in the app store. - - name: acq_app_store_ad_click_app_store_surface_detail - description: - Detailed information about the specific app store surface where an - ad click occurred. - - name: acq_mesa_install_event_start_selected - description: - Indicates whether the user selected the 'Start Free Trial' option - during the Mesa installation event. - - name: acq_app_store_organic_click_referrer_term - description: - The referrer term or search term that led to an organic click in - the app store. - - name: acq_app_store_organic_click_event_timestamp_pt - description: - The timestamp indicating when the user clicked on an organic link - in the app store, in the Pacific Time zone. - - name: acq_mesa_install_event_install_completed - description: - Indicates whether the user completed the installation process during - the Mesa installation event. - - name: acq_app_store_install_referrer - description: The referrer URL or source that led to the app store for installation. - - name: acq_app_store_ad_click_app_store_surface_type - description: The type or category of the app store surface where an ad click occurred. - - name: acq_app_store_install_referrer_source - description: - The source of the referrer that led to an app installation in the - app store. - - name: acq_app_store_install_page_location - description: - The specific page location or section in the app store where the - app was installed from. - - name: acq_app_store_organic_click_utm_content - description: - The UTM content parameter for tracking the specific content or ad - that was clicked in the app store. - - name: acq_app_store_organic_click_utm_source - description: - The UTM source parameter for tracking the origin of traffic that - led to an organic click. - - name: acq_app_store_ad_click_app_store_surface_intra_position - description: - The intra-position or specific subsection within an app store surface - where an ad click occurred. - - name: acq_app_store_ad_click_referrer_medium - description: - The medium through which the user was referred to the app store for - an ad click. - - name: acq_mesa_install_event_session - description: The session ID associated with the Mesa installation event. - - name: shopify_last_updated_at_pt - description: The timestamp of the last update to the shop in Pacific Time. - - name: acq_app_store_ad_click_utm_campaign - description: - The UTM campaign parameter used for identifying the specific marketing - campaign linked to an ad click. - - name: acq_app_store_has_ad_click - description: - Indicates whether there was a click on an advertisement within the - app store. - - name: acq_app_store_did_click_ad_before_install - description: - Flags if the user clicked on an app store ad prior to installing - the app. - - name: acq_app_store_install_source_medium - description: - The source-medium through which the user was referred to the app - store for installation. - - name: acq_app_store_ad_click_source_medium - description: - The source-medium through which the user was referred to the app - store for an ad click. - - name: acq_app_store_ad_click_device_category - description: The device category from which the app store ad click occurred. - - name: acq_app_store_install_device_category - description: The device category from which the app store install occurred. - - name: acq_app_store_organic_click_device_category - description: The device category from which the app store organic click occurred. + description: The number of days it took to install after acquisition. + - name: acq_has_app_store_organic_click + description: Whether there was an organic click in the app store during acquisition. + - name: acq_unified_traffic_medium + description: The medium of the traffic during acquisition. + - name: acq_unified_first_touch_at_pt + description: The timestamp of the first touch during acquisition in Pacific Time. + - name: acq_unified_app_store_surface_type + description: The type of surface in the app store during acquisition. + - name: acq_unified_traffic_campaign + description: The campaign of the traffic during acquisition. + - name: acq_unified_traffic_source + description: The source of the traffic during acquisition. + - name: acq_unified_referrer_host + description: The host of the referrer during acquisition. + - name: acq_unified_traffic_url + description: The URL of the traffic during acquisition. + - name: acq_unified_traffic_path + description: The path of the traffic during acquisition. + - name: acq_referrer_source + description: The source of the referrer during acquisition. + - name: acq_referrer_medium + description: The medium of the referrer during acquisition. + - name: acq_unified_traffic_page_host + description: The host of the traffic page during acquisition. + - name: acq_unified_app_store_surface_detail + description: The detail of the surface in the app store during acquisition. diff --git a/models/mesa/marts/shop_attribution.sql b/models/mesa/marts/shop_attribution.sql new file mode 100644 index 0000000..9905cd7 --- /dev/null +++ b/models/mesa/marts/shop_attribution.sql @@ -0,0 +1,3 @@ +SELECT + * +FROM {{ ref("int_shop_install_sources") }} diff --git a/models/mesa/marts/shops.sql b/models/mesa/marts/shops.sql index 00cffb4..905833c 100644 --- a/models/mesa/marts/shops.sql +++ b/models/mesa/marts/shops.sql @@ -152,18 +152,10 @@ with LEFT JOIN yesterdays USING (shop_subdomain) ), - install_sources AS ( - {% set table_name = ref("int_shop_install_sources") %} - {% set column_names = dbt_utils.get_filtered_columns_in_relation( - from=table_name, except=["shop_subdomain", "shopify_id"] - ) %} + simple_shop_attribution AS ( SELECT - shop_subdomain, - {% for column_name in column_names %} - {{ column_name }} AS acq_{{ column_name }} - {%- if not loop.last %},{% endif %} - {% endfor %} - FROM {{ table_name }} + * + FROM {{ ref('int_simplified_shop_attribution') }} ), max_funnel_steps AS ( @@ -658,7 +650,7 @@ with LEFT JOIN successful_workflow_run_counts USING (shop_subdomain) LEFT JOIN app_pageview_bookend_times USING (shop_subdomain) LEFT JOIN current_rolling_counts USING (shop_subdomain) - LEFT JOIN install_sources USING (shop_subdomain) + LEFT JOIN simple_shop_attribution USING (shop_subdomain) LEFT JOIN max_funnel_steps USING (shop_subdomain) LEFT JOIN total_ltv_revenue USING (shop_subdomain) LEFT JOIN shop_infos USING (shop_subdomain) diff --git a/models/mesa/shop_attribution.yml b/models/mesa/shop_attribution.yml new file mode 100644 index 0000000..46ea848 --- /dev/null +++ b/models/mesa/shop_attribution.yml @@ -0,0 +1,792 @@ +version: 2 +models: + - name: shop_attribution + columns: + - name: shop_subdomain + description: The subdomain of the shop. + tests: + - not_null + - name: unified_traffic_source + description: The source of the traffic that led to the shop. + - name: unified_traffic_medium + description: The medium of the traffic that led to the shop. + - name: unified_traffic_campaign + description: The campaign of the traffic that led to the shop. + - name: unified_traffic_url + description: The URL of the traffic that led to the shop. + - name: unified_traffic_path + description: The path of the traffic that led to the shop. + - name: unified_traffic_page_host + description: The page host of the traffic that led to the shop. + - name: unified_first_touch_at_pt + description: The timestamp of the first touch at the shop in Pacific Time. + - name: unified_app_store_surface_type + description: + The type of the app store surface where the user first interacted + with the shop. + - name: unified_app_store_surface_detail + description: + The detail of the app store surface where the user first interacted + with the shop. + - name: unified_referrer_host + description: The host that referred the user to the shop. + - name: is_blog_referral + description: Indicates whether the referral to the shop came from a blog. + - name: days_to_install + description: + The number of days it took for the user to install the app after + first interaction. + - name: is_app_store_search_ad_referral + description: + Indicates whether the referral to the shop came from an app store + search ad. + tests: + - not_null + - name: referrer_medium + description: The medium of the referrer that led the user to the shop. + - name: referrer_source + description: The source of the referrer that led the user to the shop. + - description: The type of the app store surface during the last touch event. + name: ga_last_touch_app_store_surface_type + - description: + The intra position of the app store surface during the first touch + event. + name: ga_first_touch_app_store_surface_intra_position + - description: The type of surface for the first touch in the app store. + name: ga_first_touch_app_store_surface_type + - description: The source of the m3_mesa_install event. + name: mesa_install_record_mesa_source + - description: The locale of the app store during the first touch event. + name: ga_first_touch_app_store_locale + - description: The timestamp of the last touch. + name: ga_last_touch_at_pt + - description: The inter position of the last touch on the app store surface. + name: ga_last_touch_app_store_surface_inter_position + - description: + The inter position of the app store surface during the first touch + event. + name: ga_first_touch_app_store_surface_inter_position + - description: The locale of the app store during the last touch event. + name: ga_last_touch_app_store_locale + - description: + The timestamp indicating when the user clicked on an advertisement + in the app store, in the Pacific Time zone. + name: app_store_ad_click_at_pt + - description: The host URL from which the organic click in the app store originated. + name: app_store_organic_click_referrer_host + - description: + The referring URL or source that led to the installation event of + the Mesa application. + name: mesa_install_record_referer + - description: + Indicates whether there was an organic click in the app store related + to the shop or app. + name: has_app_store_organic_click + - description: + The position or location within the app store where the organic click + occurred, for intermediary app store surfaces. + name: app_store_organic_click_app_store_surface_inter_position + - description: Indicates whether an ad in the app store was clicked. + name: app_store_did_click_ad + - description: + Details about the app store surface (section or category) where the + app was installed from. + name: app_store_install_app_store_surface_detail + - description: + The specific page location or section in the app store where the + ad click occurred. + name: app_store_ad_click_page_location + - description: + Detailed information about the specific app store surface where an + organic click occurred. + name: app_store_organic_click_app_store_surface_detail + - description: + The locale or regional setting of the app store during an organic + click event. + name: app_store_organic_click_app_store_locale + - description: + The locale or regional setting of the app store during an ad click + event. + name: app_store_ad_click_app_store_locale + - description: + Details the specific plan or package selected during the Mesa installation + event. + name: mesa_install_record_plan_selected + - description: + The UTM medium parameter associated with the Mesa installation event + for tracking the marketing channel. + name: mesa_install_record_utm_medium + - description: + Identifies the specific Mesa plan or tier chosen during the installation + process. + name: mesa_install_record_plan + - description: + The UTM campaign parameter related to the specific marketing campaign + during the Mesa installation event. + name: mesa_install_record_utm_campaign + - description: + The specific page location or area in the app store where an organic + click took place. + name: app_store_organic_click_page_location + - description: The name of the traffic source during the first touch event. + name: ga_first_touch_traffic_source_name + - description: The first page path that the shop was acquired through. + name: segment_acquisition_first_page_path + - description: The host of the referrer during the first touch event. + name: ga_first_touch_referrer_host + - description: The medium that the shop was acquired through. + name: ga_first_touch_traffic_source_medium + - description: The source of the traffic source during the first touch event. + name: ga_first_touch_traffic_source_source + - description: + The intra position of the app store surface during the app store + installation. + name: app_store_install_app_store_surface_intra_position + - description: The device language during the last touch event. + name: ga_last_touch_device_language + - description: The manual medium used during the app store installation. + name: app_store_install_manual_medium + - description: + The query of the page location during the organic click in the app + store. + name: app_store_organic_click_page_location_query + - description: The medium parameter during the first touch event. + name: ga_first_touch_param_medium + - description: + The URL of the page location during the organic click in the app + store. + name: app_store_organic_click_page_location_url + - description: The path during the last touch event in the segment. + name: segment_last_touch_path + - description: The device language during the organic click in the app store. + name: app_store_organic_click_device_language + - description: The manual source used during the app store installation. + name: app_store_install_manual_source + - description: The source parameter during the organic click in the app store. + name: app_store_organic_click_param_source + - description: The manual term used during the organic click in the app store. + name: app_store_organic_click_manual_term + - description: The GA session ID during the first touch event. + name: ga_first_touch_ga_session_id + - description: The city of the location during the last touch event. + name: ga_last_touch_location_city + - description: The referrer URL during the organic click in the app store. + name: app_store_organic_click_referrer_url + - description: The metro of the location during the ad click in the app store. + name: app_store_ad_click_location_metro + - description: The URL during the first touch event in the segment. + name: segment_first_touch_url + - description: The URL of the page location during the last touch event. + name: ga_last_touch_page_location_url + - description: The host of the referrer during the first touch event. + name: ga_first_touch_referrer_host + - description: The manual source used during the last touch event. + name: ga_last_touch_manual_source + - description: The continent of the location during the app store installation. + name: app_store_install_location_continent + - description: The continent of the location during the app store installation. + name: ga_last_touch_manual_campaign_name + - description: The source of the traffic source during the first touch event. + name: ga_first_touch_traffic_source_source + - description: + The host of the page location during the organic click in the app + store. + name: app_store_organic_click_page_location_host + - description: + The host of the page location during the organic click in the app + store. + name: app_store_install_manual_campaign_name + - description: The event ID during the last touch event. + name: ga_last_touch_event_id + - description: The term parameter during the last touch event. + name: ga_last_touch_param_term + - description: The page title during the app store installation. + name: app_store_install_page_title + - description: The manual source used during the organic click in the app store. + name: app_store_organic_click_manual_source + - description: The source parameter during the first touch event. + name: ga_first_touch_param_source + - description: The source parameter during the first touch event. + name: ga_last_touch_page_title + - description: The title of the page during the last touch event. + name: ga_first_touch_manual_campaign_name + - description: The device language during the first touch event. + name: ga_first_touch_device_language + - description: The country of the location during the organic click in the app store. + name: app_store_organic_click_location_country + - description: The manual source used during the first touch event. + name: ga_first_touch_manual_source + - description: The manual source used during the first touch event. + name: ga_ga4_sessions_til_install + - description: + The intra position of the app store surface during the app store + installation. + name: app_store_install_app_store_surface_intra_position + - description: The device language during the last touch event. + name: ga_last_touch_device_language + - description: The manual medium used during the app store installation. + name: app_store_install_manual_medium + - description: The medium parameter during the first touch event. + name: ga_first_touch_param_medium + - description: The path during the last touch event in the segment. + name: segment_last_touch_path + - description: The device language during the organic click in the app store. + name: app_store_organic_click_device_language + - description: The manual source used during the app store installation. + name: app_store_install_manual_source + - description: The continent of the location during the ad click in the app store. + name: app_store_ad_click_location_continent + - description: The GA session number during the ad click in the app store. + name: app_store_ad_click_ga_session_number + - description: The query of the referrer during the first touch event. + name: ga_first_touch_referrer_query + - description: The host of the referrer during the first touch event in the segment. + name: segment_first_touch_referrer_host + - description: The GA session ID during the last touch event. + name: ga_last_touch_ga_session_id + - description: The campaign parameter during the first touch event. + name: ga_first_touch_param_campaign + - description: The path of the referrer during the app store installation. + name: app_store_install_referrer_path + - description: The path of the referrer during the organic click in the app store. + name: app_store_organic_click_referrer_path + - description: The detail of the app store surface during the first touch event. + name: ga_first_touch_app_store_surface_detail + - description: The source parameter during the last touch event. + name: ga_last_touch_param_source + - description: The referrer during the first touch event in the segment. + name: segment_first_touch_referrer + - description: The full referrer during the ad click in the app store. + name: app_store_ad_click_referrer_full + - description: The continent of the location during the first touch event. + name: ga_first_touch_location_continent + - description: The term parameter during the app store installation. + name: app_store_install_param_term + - description: The campaign parameter during the ad click in the app store. + name: app_store_ad_click_param_campaign + - description: The timestamp of the first touch event in Pacific Time in the segment. + name: segment_first_touch_at_pt + - description: + The intra position of the app store surface during the first touch + event in the segment. + name: segment_first_touch_app_store_surface_intra_position + - description: The device category during the last touch event. + name: ga_last_touch_device_category + - description: The host of the page location during the last touch event. + name: ga_last_touch_page_location_host + - description: The content parameter during the app store installation. + name: app_store_install_param_content + - description: + The medium of the traffic source during the first touch event in + the segment. + name: segment_first_touch_traffic_source_medium + - description: The path of the page location during the first touch event. + name: ga_first_touch_page_location_path + - description: The medium of the traffic source during the last touch event. + name: ga_last_touch_traffic_source_medium + - description: The manual medium used during the organic click in the app store. + name: app_store_organic_click_manual_medium + - description: The referrer URL during the last touch event. + name: ga_last_touch_referrer_url + - description: The manual source used during the ad click in the app store. + name: app_store_ad_click_manual_source + - description: The manual term used during the last touch event. + name: ga_last_touch_manual_term + - description: The event ID during the ad click in the app store. + name: app_store_ad_click_event_id + - description: The device language during the ad click in the app store. + name: app_store_ad_click_device_language + - description: The metro of the location during the last touch event. + name: ga_last_touch_location_metro + - description: The full referrer during the organic click in the app store. + name: app_store_organic_click_referrer_full + - description: The locale of the app store during the first touch event in the segment. + name: segment_first_touch_app_store_locale + - description: The event ID during the first touch event. + name: ga_first_touch_event_id + - description: + The source of the traffic source during the last touch event in the + segment. + name: segment_last_touch_traffic_source_source + - description: The GA session ID during the app store installation. + name: app_store_install_ga_session_id + - description: The source of the traffic source during the app store installation. + name: app_store_install_traffic_source_source + - description: The city of the location during the organic click in the app store. + name: app_store_organic_click_location_city + - description: The GA session ID during the ad click in the app store. + name: app_store_ad_click_ga_session_id + - description: The campaign parameter during the app store installation. + name: app_store_install_param_campaign + - description: The URL of the page location during the app store installation. + name: app_store_install_page_location_url + - description: The source of the traffic source during the ad click in the app store. + name: app_store_ad_click_traffic_source_source + - description: The content parameter during the last touch event. + name: ga_last_touch_param_content + - description: The host of the referrer during the last touch event. + name: ga_last_touch_referrer_host + - description: The medium of the traffic source during the app store installation. + name: app_store_install_traffic_source_medium + - description: + The inter position of the app store surface during the first touch + event in the segment. + name: segment_first_touch_app_store_surface_inter_position + - description: + The source of the traffic source during the first touch event in + the segment. + name: segment_first_touch_traffic_source_source + - description: The title of the page during the ad click in the app store. + name: app_store_ad_click_page_title + - description: The location of the page during the last touch event. + name: ga_last_touch_page_location + - description: The manual term used during the app store installation. + name: app_store_install_manual_term + - description: The full referrer during the first touch event. + name: ga_first_touch_referrer_full + - description: The query of the referrer during the organic click in the app store. + name: app_store_organic_click_referrer_query + - description: + The type of the app store surface during the first touch event in + the segment. + name: segment_first_touch_app_store_surface_type + - description: The campaign parameter during the organic click in the app store. + name: app_store_organic_click_param_campaign + - description: The content parameter during the ad click in the app store. + name: app_store_ad_click_param_content + - description: The query of the page location during the app store installation. + name: app_store_install_page_location_query + - description: The device language during the app store installation. + name: app_store_install_device_language + - description: The term parameter during the first touch event. + name: ga_first_touch_param_term + - description: + The intra position of the app store surface during the app store + installation. + name: app_store_install_app_store_surface_intra_position + - description: The device language during the last touch event. + name: ga_last_touch_device_language + - description: + The query of the page location during the organic click in the app + store. + name: app_store_organic_click_page_location_query + - description: + The URL of the page location during the organic click in the app + store. + name: app_store_organic_click_page_location_url + - description: The path during the last touch event in the segment. + name: segment_last_touch_path + - description: The device language during the organic click in the app store. + name: app_store_organic_click_device_language + - description: The manual medium used during the ad click in the app store. + name: app_store_ad_click_manual_medium + - description: The device category during the first touch event. + name: ga_first_touch_device_category + - description: The GA session ID during the first touch event. + name: ga_first_touch_ga_session_id + - description: The city of the location during the last touch event. + name: ga_last_touch_location_city + - description: The GCLID during the last touch event. + name: ga_last_touch_gclid + - description: The term parameter during the ad click in the app store. + name: app_store_ad_click_param_term + - description: The event ID during the organic click in the app store. + name: app_store_organic_click_event_id + - description: The continent of the location during the ad click in the app store. + name: app_store_ad_click_location_continent + - description: The GA session number during the ad click in the app store. + name: app_store_ad_click_ga_session_number + - description: The query of the referrer during the first touch event. + name: ga_first_touch_referrer_query + - description: The host of the referrer during the first touch event in the segment. + name: segment_first_touch_referrer_host + - description: The GA session ID during the last touch event. + name: ga_last_touch_ga_session_id + - description: The campaign parameter during the first touch event. + name: ga_first_touch_param_campaign + - description: The path of the referrer during the app store installation. + name: app_store_install_referrer_path + - description: The path of the referrer during the organic click in the app store. + name: app_store_organic_click_referrer_path + - description: The detail of the app store surface during the first touch event. + name: ga_first_touch_app_store_surface_detail + - description: The source parameter during the last touch event. + name: ga_last_touch_param_source + - description: The referrer during the first touch event in the segment. + name: segment_first_touch_referrer + - description: The full referrer during the ad click in the app store. + name: app_store_ad_click_referrer_full + - description: + The intra position of the app store surface during the first touch + event. + name: ga_first_touch_app_store_surface_intra_position + - description: The country of the location during the last touch event. + name: ga_last_touch_location_country + - description: The locale of the app store during the last touch event. + name: ga_last_touch_app_store_locale + - description: The GCLID during the app store installation. + name: app_store_install_gclid + - description: The page title during the organic click in the app store. + name: app_store_organic_click_page_title + - description: + The continent of the location during the organic click in the app + store. + name: app_store_organic_click_location_continent + - description: The continent of the location during the first touch event. + name: ga_first_touch_location_continent + - description: The term parameter during the app store installation. + name: app_store_install_param_term + - description: The campaign parameter during the ad click in the app store. + name: app_store_ad_click_param_campaign + - description: + The intra position of the app store surface during the first touch + event in the segment. + name: segment_first_touch_app_store_surface_intra_position + - description: The device category during the last touch event. + name: ga_last_touch_device_category + - description: The host of the page location during the last touch event. + name: ga_last_touch_page_location_host + - description: The content parameter during the app store installation. + name: app_store_install_param_content + - description: + The medium of the traffic source during the first touch event in + the segment. + name: segment_first_touch_traffic_source_medium + - description: The path of the page location during the first touch event. + name: ga_first_touch_page_location_path + - description: The timestamp of the last touch event in the segment in Pacific Time. + name: segment_last_touch_at_pt + - description: The manual medium used during the organic click in the app store. + name: app_store_organic_click_manual_medium + - description: The manual source used during the ad click in the app store. + name: app_store_ad_click_manual_source + - description: The device language during the ad click in the app store. + name: app_store_ad_click_device_language + - description: The metro of the location during the last touch event. + name: ga_last_touch_location_metro + - description: The full referrer during the organic click in the app store. + name: app_store_organic_click_referrer_full + - description: The locale of the app store during the first touch event in the segment. + name: segment_first_touch_app_store_locale + - description: The event ID during the first touch event. + name: ga_first_touch_event_id + - description: + The source of the traffic source during the last touch event in the + segment. + name: segment_last_touch_traffic_source_source + - description: The GA session ID during the app store installation. + name: app_store_install_ga_session_id + - description: The source of the traffic source during the app store installation. + name: app_store_install_traffic_source_source + - description: The city of the location during the organic click in the app store. + name: app_store_organic_click_location_city + - description: The GA session ID during the ad click in the app store. + name: app_store_ad_click_ga_session_id + - description: The campaign parameter during the app store installation. + name: app_store_install_param_campaign + - description: The URL of the page location during the app store installation. + name: app_store_install_page_location_url + - description: The source of the traffic source during the ad click in the app store. + name: app_store_ad_click_traffic_source_source + - description: The GCLID during the organic click in the app store. + name: app_store_organic_click_gclid + - description: The city of the location during the first touch event. + name: ga_first_touch_location_city + - description: The content parameter during the last touch event. + name: ga_last_touch_param_content + - description: The host of the referrer during the last touch event. + name: ga_last_touch_referrer_host + - description: The medium of the traffic source during the app store installation. + name: app_store_install_traffic_source_medium + - description: The source of the traffic source during the last touch event. + name: ga_last_touch_traffic_source_source + - description: The timestamp of the app store installation in Pacific Time. + name: app_store_install_at_pt + - description: + The inter position of the app store surface during the first touch + event in the segment. + name: segment_first_touch_app_store_surface_inter_position + - description: The location of the page during the last touch event. + name: ga_last_touch_page_location + - description: The manual term used during the app store installation. + name: app_store_install_manual_term + - description: The full referrer during the first touch event. + name: ga_first_touch_referrer_full + - description: The query of the referrer during the organic click in the app store. + name: app_store_organic_click_referrer_query + - description: + The type of the app store surface during the first touch event in + the segment. + name: segment_first_touch_app_store_surface_type + - description: The campaign parameter during the organic click in the app store. + name: app_store_organic_click_param_campaign + - description: The content parameter during the ad click in the app store. + name: app_store_ad_click_param_content + - description: The query of the page location during the app store installation. + name: app_store_install_page_location_query + - description: The device language during the app store installation. + name: app_store_install_device_language + - description: The term parameter during the first touch event. + name: ga_first_touch_param_term + - name: ga_first_touch_manual_term + description: The manual term used during the first touch event. + - description: The manual term used during the first touch event. + name: ga_first_touch_manual_term + - description: + The name of the traffic source during the last touch event in the + segment. + name: segment_last_touch_traffic_source_name + - description: + The name of the manual campaign during the organic click in the app + store. + name: app_store_organic_click_manual_campaign_name + - description: The manual term used during the ad click in the app store. + name: app_store_ad_click_manual_term + - description: The name of the traffic source during the ad click in the app store. + name: app_store_ad_click_traffic_source_name + - description: The continent of the location during the last touch event. + name: ga_last_touch_location_continent + - description: The source parameter during the app store installation. + name: app_store_install_param_source + - description: The path of the referrer during the ad click in the app store. + name: app_store_ad_click_referrer_path + - description: The name of the manual campaign during the ad click in the app store. + name: app_store_ad_click_manual_campaign_name + - description: The timestamp of the organic click in the app store in Pacific Time. + name: app_store_organic_click_at_pt + - description: The country of the location during the app store installation. + name: app_store_install_location_country + - description: The referrer URL during the app store installation. + name: app_store_install_referrer_url + - description: The medium parameter during the ad click in the app store. + name: app_store_ad_click_param_medium + - description: The device category during the first touch event in the segment. + name: segment_first_touch_device_category + - description: The query of the page location during the last touch event. + name: ga_last_touch_page_location_query + - description: The medium parameter during the last touch event. + name: ga_last_touch_param_medium + - description: The URL during the last touch event in the segment. + name: segment_last_touch_url + - description: The content parameter during the first touch event. + name: ga_first_touch_param_content + - description: The URL of the page location during the ad click in the app store. + name: app_store_ad_click_page_location_url + - description: The query of the page location during the ad click in the app store. + name: app_store_ad_click_page_location_query + - description: The GA session number during the first touch event. + name: ga_first_touch_ga_session_number + - description: The manual content used during the ad click in the app store. + name: app_store_ad_click_manual_content + - description: The name of the traffic source during the app store installation. + name: app_store_install_traffic_source_name + - description: The medium parameter during the organic click in the app store. + name: app_store_organic_click_param_medium + - description: The title of the page during the first touch event. + name: ga_first_touch_page_title + - description: The referrer during the last touch event in the segment. + name: segment_last_touch_referrer + - description: The medium of the traffic source during the ad click in the app store. + name: app_store_ad_click_traffic_source_medium + - description: The query of the page location during the first touch event. + name: ga_first_touch_page_location_query + - description: The metro of the location during the first touch event. + name: ga_first_touch_location_metro + - description: + The detail of the app store surface during the first touch event + in the segment. + name: segment_first_touch_app_store_surface_detail + - description: The country of the location during the first touch event. + name: ga_first_touch_location_country + - description: The path of the page location during the app store installation. + name: app_store_install_page_location_path + - description: The city of the location during the ad click in the app store. + name: app_store_ad_click_location_city + - description: The campaign parameter during the last touch event. + name: ga_last_touch_param_campaign + - description: The host of the page location during the ad click in the app store. + name: app_store_ad_click_page_location_host + - description: The GA session number during the app store installation. + name: app_store_install_ga_session_number + - description: The query of the referrer during the last touch event. + name: ga_last_touch_referrer_query + - description: + The name of the traffic source during the organic click in the app + store. + name: app_store_organic_click_traffic_source_name + - description: The path of the referrer during the last touch event. + name: ga_last_touch_referrer_path + - description: The GA session number during the last touch event. + name: ga_last_touch_ga_session_number + - description: The number of segment sessions until installation. + name: segment_segment_sessions_til_install + - description: The GCLID during the ad click in the app store. + name: app_store_ad_click_gclid + - description: + The medium of the traffic source during the last touch event in the + segment. + name: segment_last_touch_traffic_source_medium + - description: The acquisition template. + name: acquisition_template + - description: The manual medium used during the last touch event. + name: ga_last_touch_manual_medium + - description: The URL of the page location during the first touch event. + name: ga_first_touch_page_location_url + - description: + The name of the traffic source during the first touch event in the + segment. + name: segment_first_touch_traffic_source_name + - description: The source parameter during the app store installation. + name: app_store_install_param_medium + - description: The query of the referrer during the app store installation. + name: app_store_install_referrer_query + - description: The path of the referrer during the first touch event. + name: ga_first_touch_referrer_path + - description: The content parameter during the organic click in the app store. + name: app_store_organic_click_param_content + - description: The metro of the location during the app store installation. + name: app_store_install_location_metro + - description: The location of the page during the first touch event. + name: ga_first_touch_page_location + - description: The Shopify ID in the segment. + name: segment_shopify_id + - description: + The medium of the traffic source during the organic click in the + app store. + name: app_store_organic_click_traffic_source_medium + - description: The host of the page location during the app store installation. + name: app_store_install_page_location_host + - description: The manual content used during the app store installation. + name: app_store_install_manual_content + - description: The GCLID during the first touch event. + name: ga_first_touch_gclid + - description: + The path of the page location during the organic click in the app + store. + name: app_store_organic_click_page_location_path + - description: The detail of the app store surface during the last touch event. + name: ga_last_touch_app_store_surface_detail + - description: + The intra position of the app store surface during the last touch + event. + name: ga_last_touch_app_store_surface_intra_position + - description: The full referrer during the app store installation. + name: app_store_install_referrer_full + - description: The manual medium used during the first touch event. + name: ga_first_touch_manual_medium + - description: The host of the page location during the first touch event. + name: ga_first_touch_page_location_host + - description: The full referrer during the last touch event. + name: ga_last_touch_referrer_full + - description: The query of the referrer during the ad click in the app store. + name: app_store_ad_click_referrer_query + - description: The country of the location during the ad click in the app store. + name: app_store_ad_click_location_country + - description: + Detailed information about the specific app store surface where an + ad click occurred. + name: app_store_ad_click_app_store_surface_detail + - description: The URL of the referrer during the first touch event. + name: ga_first_touch_referrer_url + - description: + The locale or regional setting of the app store during an installation + event. + name: app_store_install_app_store_locale + - description: The host URL from which the installation in the app store originated. + name: app_store_install_referrer_host + - description: The type of surface where the ad click occurred in the app store. + name: app_store_ad_click_app_store_surface_type + - description: The category of the device used during the app store installation. + name: app_store_install_device_category + - description: The type of surface where the installation occurred in the app store. + name: app_store_install_app_store_surface_type + - description: Whether there was an ad click before the app store installation. + name: app_store_has_ad_click + - description: Whether the Mesa installation was completed. + name: mesa_install_record_install_completed + - description: + The timestamp indicating when the Mesa installation occurred, in + the Pacific Time zone. + name: mesa_install_record_at_pt + - description: + The category of the device used during the organic click in the app + store. + name: app_store_organic_click_device_category + - description: The host URL from which the ad click in the app store originated. + name: app_store_ad_click_referrer_host + - description: Whether there was an ad click before the app store installation. + name: app_store_did_click_ad_before_install + - description: + The intra position of the app store surface during the organic click + event. + name: app_store_organic_click_app_store_surface_intra_position + - description: The category of the device used during the ad click in the app store. + name: app_store_ad_click_device_category + - description: + The specific page location or section in the app store where the + installation occurred. + name: app_store_install_page_location + - description: The type of click (ad or organic) in the app store. + name: app_store_click_type + - description: The intra position of the app store surface during the ad click event. + name: app_store_ad_click_app_store_surface_intra_position + - description: The type of surface where the organic click occurred in the app store. + name: app_store_organic_click_app_store_surface_type + - description: + Details the specific plan or package selected during the Mesa installation + event. + name: mesa_install_record_start_selected + - description: + The UTM source parameter associated with the Mesa installation event + for tracking the marketing channel. + name: mesa_install_record_utm_source + - description: The inter position of the app store surface during the ad click event. + name: app_store_ad_click_app_store_surface_inter_position + - description: The content of the traffic source during the last touch event in Segment. + name: segment_last_touch_traffic_source_content + - description: The source of the traffic during the organic click in the app store. + name: app_store_organic_click_traffic_source_source + - description: The name of the traffic source during the last touch event in Google Analytics. + name: ga_last_touch_traffic_source_name + - description: The host of the referrer during the last touch event in Segment. + name: segment_last_touch_referrer_host + - description: The category of the device used during the last touch event in Segment. + name: segment_last_touch_device_category + - description: The city of the location during the app store installation. + name: app_store_install_location_city + - description: The path during the first touch event in Segment. + name: segment_first_touch_path + - description: The path of the page location during the last touch event in Google Analytics. + name: ga_last_touch_page_location_path + - description: The path of the page location during the ad click in the app store. + name: app_store_ad_click_page_location_path + - description: The source parameter during the ad click in the app store. + name: app_store_ad_click_param_source + - description: The host during the first touch event in Segment. + name: segment_first_touch_host + - description: The URL of the referrer during the ad click in the app store. + name: app_store_ad_click_referrer_url + - description: The manual content during the first touch event in Google Analytics. + name: ga_first_touch_manual_content + - description: The Google Analytics session number during the organic click in the app store. + name: app_store_organic_click_ga_session_number + - description: The event ID during the app store installation. + name: app_store_install_event_id + - description: The Google Analytics session ID during the organic click in the app store. + name: app_store_organic_click_ga_session_id + - description: The host during the last touch event in Segment. + name: segment_last_touch_host + - description: The metro area of the location during the organic click in the app store. + name: app_store_organic_click_location_metro + - description: The manual content during the organic click in the app store. + name: app_store_organic_click_manual_content + - description: The term parameter during the organic click in the app store. + name: app_store_organic_click_param_term + - description: The manual content during the last touch event in Google Analytics. + name: ga_last_touch_manual_content + - description: The inter position of the app store surface during the app store installation. + name: app_store_install_app_store_surface_inter_position + - description: The timestamp indicating when the first touch event occurred in Google Analytics, in the Pacific Time zone. + name: ga_first_touch_at_pt + - description: The content of the traffic source during the first touch event in Segment. + name: segment_first_touch_traffic_source_content``` diff --git a/models/mesa/sources.yml b/models/mesa/sources.yml index f1c7e7d..015f37f 100644 --- a/models/mesa/sources.yml +++ b/models/mesa/sources.yml @@ -79,7 +79,7 @@ sources: - name: created_at tests: - not_null - - name: mesa_install_events + - name: mesa_install_records identifier: m3_mesa_installs - name: blog_studio_shops identifier: m3_blogstudio diff --git a/models/mesa/staging/stg_mesa_install_records.sql b/models/mesa/staging/stg_mesa_install_records.sql new file mode 100644 index 0000000..943b770 --- /dev/null +++ b/models/mesa/staging/stg_mesa_install_records.sql @@ -0,0 +1,41 @@ +WITH source AS ( + SELECT + * RENAME uuid AS shop_subdomain, + ROW_NUMBER() OVER (PARTITION BY uuid ORDER BY created_at DESC) AS row_num + FROM {{ source("mongo_sync", "mesa_install_records") }} + WHERE + install_completed + AND + uuid IS NOT NULL +), + +final AS ( + + select + shop_subdomain, + {{ get_prefixed_columns(source("mongo_sync", "mesa_install_records"), 'mesa_install_record', + exclude=[ + "template", + "state", + 'uuid', + "mesa_id", + "__hevo__ingested_at", + "__hevo__loaded_at", + "__hevo__database_name", + "updated_at", + "utm_term", + "route", + "ip", + "__hevo__marked_deleted", + "_created_at", + "_id", + "session" + ], + ) }}, + template as acquisition_template + FROM source + WHERE row_num = 1 +) + +SELECT * +FROM final diff --git a/models/mesa/stg_ga4_events.yml b/models/mesa/stg_ga4_events.yml new file mode 100644 index 0000000..459ad97 --- /dev/null +++ b/models/mesa/stg_ga4_events.yml @@ -0,0 +1,48 @@ +version: 2 +models: + - name: stg_ga4_events + columns: + - name: page_location + - name: page_title + - name: traffic_source_name + - name: event_name + - name: user_pseudo_id + - name: traffic_source_medium + - name: traffic_source_source + - name: device_category + - name: event_id + - name: shop_subdomain + description: The subdomain of the shop. + - name: param_campaign + - name: param_source + - name: param_medium + - name: page_referrer + - name: shopify_id + - name: ga_session_id + - name: ga_session_number + - name: continent + - name: country + - name: city + - name: metro + - name: language + - name: manual_campaign_name + - name: gclid + - name: manual_medium + - name: manual_source + - name: manual_term + - name: manual_content + - name: event_timestamp_pt + - name: param_content + - name: param_term + - name: referrer + - name: referrer_host + - name: referrer_source + description: The source of the referrer that led the user to the shop. + - name: referrer_medium + description: The medium of the referrer that led the user to the shop. + - name: referrer_term + - name: app_store_surface_detail + - name: app_store_surface_type + - name: app_store_surface_intra_position + - name: app_store_surface_inter_position + - name: app_store_locale diff --git a/models/mesa/stg_segment_first_visits.yml b/models/mesa/stg_segment_first_visits.yml index 9ebbc2e..6bfd427 100644 --- a/models/mesa/stg_segment_first_visits.yml +++ b/models/mesa/stg_segment_first_visits.yml @@ -16,11 +16,11 @@ models: description: The path of the first touch. - name: first_touch_content description: The content that the shop was acquired through. - - name: first_touch_campaign + - name: first_touch_traffic_source_name description: The campaign that the shop was acquired through. - - name: first_touch_medium + - name: first_touch_traffic_source_medium description: The medium that the shop was acquired through. - - name: first_touch_source + - name: first_touch_traffic_source_source description: The source that the shop was acquired through. - name: first_touch_referrer_host description: The referrer host that referrered the shop's first visit. diff --git a/models/mesa_segment/staging/stg_segment_first_visits.sql b/models/mesa_segment/staging/stg_segment_first_visits.sql index 6af28d3..536a0da 100644 --- a/models/mesa_segment/staging/stg_segment_first_visits.sql +++ b/models/mesa_segment/staging/stg_segment_first_visits.sql @@ -50,10 +50,10 @@ with first_page_url_host as first_touch_host, first_page_url_path as first_touch_path, first_page_url_query AS first_touch_query, - utm_content as first_touch_content, - utm_campaign as first_touch_campaign, - coalesce(utm_medium, referrer_medium) as first_touch_medium, - coalesce(utm_source, referrer_source) as first_touch_source, + utm_content as first_touch_traffic_source_content, + utm_campaign as first_touch_traffic_source_name, + coalesce(utm_medium, referrer_medium) as first_touch_traffic_source_medium, + coalesce(utm_source, referrer_source) as first_touch_traffic_source_source, nullif( TRIM(lower( {{ target.schema }}.url_decode( diff --git a/models/mesa_segment/staging/stg_segment_last_touch_sessions_before_install.sql b/models/mesa_segment/staging/stg_segment_last_touch_sessions_before_install.sql index 332609e..d4abc97 100644 --- a/models/mesa_segment/staging/stg_segment_last_touch_sessions_before_install.sql +++ b/models/mesa_segment/staging/stg_segment_last_touch_sessions_before_install.sql @@ -57,33 +57,10 @@ with first_page_url_host as last_touch_host, first_page_url_path as last_touch_path, first_page_url_query AS last_touch_query, - utm_content as last_touch_content, - utm_campaign as last_touch_campaign, - coalesce(utm_medium, referrer_medium) as last_touch_medium, - coalesce(utm_source, referrer_source) as last_touch_source, - TRIM( - nullif( - lower( - {{ target.schema }}.url_decode( - cast(page_params:parameters:surface_detail as string) - ) - ) - , - 'undefined' - ) - ) as last_touch_app_store_surface_detail, - cast( - page_params:parameters:surface_type as string - ) as last_touch_app_store_surface_type, - cast( - page_params:parameters:surface_intra_position as string - ) as last_touch_app_store_surface_intra_position, - cast( - page_params:parameters:surface_inter_position as string - ) as last_touch_app_store_surface_inter_position, - cast( - page_params:parameters:locale as string - ) as last_touch_app_store_locale, + utm_content as last_touch_traffic_source_content, + utm_campaign as last_touch_traffic_source_name, + coalesce(utm_medium, referrer_medium) as last_touch_traffic_source_medium, + coalesce(utm_source, referrer_source) as last_touch_traffic_source_source, referrer as last_touch_referrer, referrer_host as last_touch_referrer_host, device_category as last_touch_device_category