Skip to content

Commit 4957d26

Browse files
authored
feat(DENG-9450): Create firefoxdotcom.glean_ga_desktop_conversions (#8254)
1 parent 7cc450d commit 4957d26

File tree

4 files changed

+133
-0
lines changed

4 files changed

+133
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE OR REPLACE VIEW
2+
`moz-fx-data-shared-prod.firefoxdotcom.glean_ga_desktop_conversions`
3+
AS
4+
SELECT
5+
*
6+
FROM
7+
`moz-fx-data-shared-prod.firefoxdotcom_derived.glean_ga_desktop_conversions_v1`
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
friendly_name: Glean Google Analytics Desktop Conversions
2+
description: |-
3+
Query that pulls conversion event data for marketing campaigns
4+
owners:
5+
6+
labels:
7+
incremental: true
8+
owner1: kwindau
9+
scheduling:
10+
dag_name: bqetl_census_feed
11+
depends_on_past: true
12+
bigquery:
13+
time_partitioning:
14+
type: day
15+
field: activity_date
16+
require_partition_filter: false
17+
expiration_days: null
18+
range_partitioning: null
19+
clustering:
20+
fields:
21+
- conversion_name
22+
references: {}
23+
workgroup_access:
24+
- role: roles/bigquery.dataViewer
25+
members:
26+
- workgroup:dataops-managed/external-census
27+
- workgroup:google-managed/external-ads-datafusion
28+
- workgroup:google-managed/external-ads-dataproc
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
WITH potential_new_conversions AS (
2+
SELECT
3+
activity_date,
4+
FORMAT_DATETIME("%F %T", DATETIME(activity_date, TIME(23, 59, 59))) AS activity_datetime,
5+
@submission_date AS run_date,
6+
gclid,
7+
-- Names as represented in Google Ads
8+
-- https://docs.google.com/spreadsheets/d/1YzhhvbpOlqPLORRJUZ55BIb0H20hwFqQFApR-r0UMfI
9+
CASE
10+
conversion_name
11+
WHEN "did_firefox_first_run"
12+
THEN "firefox_first_run"
13+
WHEN "did_search"
14+
THEN "firefox_first_search"
15+
WHEN "did_click_ad"
16+
THEN "firefox_first_ad_click"
17+
WHEN "did_returned_second_day"
18+
THEN "firefox_second_run"
19+
WHEN "first_wk_5_actv_days_and_1_or_more_search_w_ads"
20+
THEN "first_wk_5_actv_days_and_1_or_more_search_w_ads"
21+
WHEN "first_wk_3_actv_days_and_1_or_more_search_w_ads"
22+
THEN "first_wk_3_actv_days_and_1_or_more_search_w_ads"
23+
WHEN "first_wk_3_actv_days_and_24_active_minutes"
24+
THEN "first_wk_3_actv_days_and_24_active_minutes"
25+
WHEN "is_dau_at_least_4_of_first_7_days"
26+
THEN "is_dau_at_least_4_of_first_7_days"
27+
WHEN "is_dau_at_least_3_of_first_7_days"
28+
THEN "is_dau_at_least_3_of_first_7_days"
29+
WHEN "is_dau_at_least_2_of_first_7_days"
30+
THEN "is_dau_at_least_2_of_first_7_days"
31+
ELSE NULL
32+
END AS conversion_name,
33+
FROM
34+
`moz-fx-data-shared-prod.firefoxdotcom_derived.glean_gclid_conversions_v1` UNPIVOT(
35+
did_conversion FOR conversion_name IN (
36+
did_firefox_first_run,
37+
did_search,
38+
did_click_ad,
39+
did_returned_second_day,
40+
first_wk_5_actv_days_and_1_or_more_search_w_ads,
41+
first_wk_3_actv_days_and_1_or_more_search_w_ads,
42+
first_wk_3_actv_days_and_24_active_minutes,
43+
is_dau_at_least_4_of_first_7_days,
44+
is_dau_at_least_3_of_first_7_days,
45+
is_dau_at_least_2_of_first_7_days
46+
)
47+
)
48+
WHERE
49+
did_conversion
50+
AND activity_date = @submission_date
51+
),
52+
--Google rejects clicks coming multiple days for the same conversion event
53+
--so we exclude any that we had already sent
54+
prior_click_conversion_combos AS (
55+
SELECT DISTINCT
56+
gclid,
57+
conversion_name,
58+
1 AS reported_on_different_day_already
59+
FROM
60+
`moz-fx-data-shared-prod.firefoxdotcom_derived.glean_ga_desktop_conversions_v1`
61+
WHERE
62+
activity_date < @submission_date
63+
)
64+
SELECT DISTINCT
65+
a.activity_date,
66+
a.activity_datetime,
67+
a.run_date,
68+
a.gclid,
69+
a.conversion_name
70+
FROM
71+
potential_new_conversions a
72+
LEFT OUTER JOIN
73+
prior_click_conversion_combos b
74+
ON a.gclid = b.gclid
75+
AND a.conversion_name = b.conversion_name
76+
WHERE
77+
COALESCE(b.reported_on_different_day_already, 0) != 1
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
fields:
2+
- name: activity_date
3+
mode: NULLABLE
4+
type: DATE
5+
description: Activity Date
6+
- name: activity_datetime
7+
mode: NULLABLE
8+
type: STRING
9+
description: Activity Datetime
10+
- name: run_date
11+
mode: NULLABLE
12+
type: DATE
13+
description: Run Date - The submission date
14+
- name: gclid
15+
mode: NULLABLE
16+
type: STRING
17+
description: Google Click ID
18+
- name: conversion_name
19+
mode: NULLABLE
20+
type: STRING
21+
description: Conversion Name

0 commit comments

Comments
 (0)