Deng 2579 gclid conversions v2 creation (#4972)
* initial commit of code for gclid_conversions_v2 * change owners to Marlene and Katie * add gclid_conversions_v2 to Access Denied bqetl_project.yaml
This commit is contained in:
Родитель
378ce60be3
Коммит
373fa54c61
|
@ -190,6 +190,7 @@ dry_run:
|
|||
- sql/moz-fx-data-shared-prod/stub_attribution_service_derived/dl_token_ga_attribution_lookup_v1/query.sql
|
||||
- sql/moz-fx-data-shared-prod/stub_attribution_service/dl_token_ga_attribution_lookup/view.sql
|
||||
- sql/moz-fx-data-shared-prod/mozilla_org_derived/gclid_conversions_v1/query.sql
|
||||
- sql/moz-fx-data-shared-prod/mozilla_org_derived/gclid_conversions_v2/query.sql
|
||||
- sql/moz-fx-data-shared-prod/mozilla_org/gclid_conversions/view.sql
|
||||
# Materialized views
|
||||
- sql/moz-fx-data-shared-prod/telemetry_derived/experiment_search_events_live_v1/init.sql
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#fail
|
||||
{{ is_unique(["gclid", "activity_date"]) }}
|
|
@ -0,0 +1,28 @@
|
|||
friendly_name: Gclid Conversions
|
||||
description: |-
|
||||
All conversions for GCLIDs.
|
||||
Partitioned by activity_date; a single GCLID
|
||||
can have multiple entries in this table,
|
||||
if they perform different conversion actions
|
||||
on different days.
|
||||
owners:
|
||||
- mhirose@mozilla.com
|
||||
- kwindau@mozilla.com
|
||||
labels:
|
||||
incremental: true
|
||||
owner1: mhirose@mozilla.com
|
||||
scheduling:
|
||||
dag_name: bqetl_mozilla_org_derived
|
||||
date_partition_parameter: activity_date
|
||||
parameters: ["conversion_window:INT64:30"]
|
||||
bigquery:
|
||||
time_partitioning:
|
||||
type: day
|
||||
field: 'activity_date'
|
||||
require_partition_filter: false
|
||||
expiration_days: null
|
||||
references: {}
|
||||
deprecated: false
|
||||
workgroup_access:
|
||||
- role: roles/bigquery.dataViewer
|
||||
members: [workgroup:dataops-managed/external-census]
|
|
@ -0,0 +1,71 @@
|
|||
WITH gclids_to_ga_ids AS (
|
||||
SELECT
|
||||
gclid,
|
||||
ga_client_id,
|
||||
stub_session_id,
|
||||
FROM
|
||||
mozilla_org_derived.ga_sessions_v2
|
||||
CROSS JOIN
|
||||
UNNEST(all_reported_stub_session_ids) AS stub_session_id
|
||||
WHERE
|
||||
session_date >= DATE_SUB(@activity_date, INTERVAL @conversion_window DAY)
|
||||
AND gclid IS NOT NULL
|
||||
),
|
||||
ga_ids_to_dl_token AS (
|
||||
SELECT
|
||||
ga_client_id,
|
||||
stub_session_id,
|
||||
dl_token,
|
||||
FROM
|
||||
stub_attribution_service_derived.dl_token_ga_attribution_lookup_v1
|
||||
WHERE
|
||||
ga_client_id IS NOT NULL
|
||||
AND stub_session_id IS NOT NULL
|
||||
),
|
||||
dl_token_to_telemetry_id AS (
|
||||
SELECT
|
||||
client_id AS telemetry_client_id,
|
||||
first_seen_date,
|
||||
attribution_dltoken AS dl_token,
|
||||
FROM
|
||||
telemetry_derived.clients_first_seen_v2
|
||||
),
|
||||
telemetry_id_to_activity AS (
|
||||
SELECT
|
||||
client_id AS telemetry_client_id,
|
||||
submission_date AS activity_date,
|
||||
search_count_all > 0 AS did_search,
|
||||
ad_clicks_count_all > 0 AS did_click_ad,
|
||||
TRUE AS was_active,
|
||||
FROM
|
||||
telemetry_derived.clients_daily_v6
|
||||
WHERE
|
||||
submission_date = @activity_date
|
||||
)
|
||||
SELECT
|
||||
activity_date,
|
||||
gclid,
|
||||
COALESCE(
|
||||
LOGICAL_OR(was_active AND activity_date = first_seen_date),
|
||||
FALSE
|
||||
) AS did_firefox_first_run,
|
||||
COALESCE(LOGICAL_OR(did_search), FALSE) AS did_search,
|
||||
COALESCE(LOGICAL_OR(did_click_ad), FALSE) AS did_click_ad,
|
||||
COALESCE(
|
||||
LOGICAL_OR(was_active AND activity_date > first_seen_date),
|
||||
FALSE
|
||||
) AS did_returned_second_day,
|
||||
FROM
|
||||
gclids_to_ga_ids
|
||||
INNER JOIN
|
||||
ga_ids_to_dl_token
|
||||
USING (ga_client_id, stub_session_id)
|
||||
INNER JOIN
|
||||
dl_token_to_telemetry_id
|
||||
USING (dl_token)
|
||||
INNER JOIN
|
||||
telemetry_id_to_activity
|
||||
USING (telemetry_client_id)
|
||||
GROUP BY
|
||||
activity_date,
|
||||
gclid
|
|
@ -0,0 +1,25 @@
|
|||
fields:
|
||||
- name: activity_date
|
||||
mode: NULLABLE
|
||||
type: DATE
|
||||
description: "The date that the conversion action took place."
|
||||
- name: gclid
|
||||
mode: NULLABLE
|
||||
type: STRING
|
||||
description: "A Google Click ID, which uniquely represent an ad impression for Google ads."
|
||||
- name: did_firefox_first_run
|
||||
mode: NULLABLE
|
||||
type: BOOLEAN
|
||||
description: "Whether the GA session associated with this GCLID resulted in a Firefox install which ran the first time on this day."
|
||||
- name: did_search
|
||||
mode: NULLABLE
|
||||
type: BOOLEAN
|
||||
description: "Whether the GA session associated with this GCLID resulted in a Firefox install with a search on this day."
|
||||
- name: did_click_ad
|
||||
mode: NULLABLE
|
||||
type: BOOLEAN
|
||||
description: "Whether the GA session associated with this GCLID resulted in a Firefox install with an ad click on this day."
|
||||
- name: did_returned_second_day
|
||||
mode: NULLABLE
|
||||
type: BOOLEAN
|
||||
description: "Whether the GA session associated with this GCLID resulted in a Firefox install that returned on this day."
|
Загрузка…
Ссылка в новой задаче