-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new view for desktop conversion events (#6309)
* Create new view for desktop conversion events * Update view.sql * Update view.sql * Update view.sql
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
sql/moz-fx-data-shared-prod/mozilla_org/desktop_conversion_events/view.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CREATE OR REPLACE VIEW | ||
`moz-fx-data-shared-prod.mozilla_org.desktop_conversion_events` | ||
AS | ||
-- Get all clicks not originating from Europe and the first session date associated with that click | ||
WITH all_clicks_not_originating_in_europe AS ( | ||
SELECT | ||
gclid, | ||
MIN(session_date) AS first_session_date | ||
FROM | ||
`moz-fx-data-shared-prod.mozilla_org_derived.ga_sessions_v2` AS ga_sessions_v2, | ||
UNNEST(gclid_array) AS gclid | ||
JOIN | ||
`moz-fx-data-shared-prod.static.country_codes_v1` c | ||
ON ga_sessions_v2.country = c.name | ||
WHERE | ||
region_name != 'Europe' | ||
GROUP BY | ||
gclid | ||
) | ||
--Get all conversion events and associated clicks in the last 89 days | ||
--where the click ID did not originate in Europe | ||
--and the click's first seen session date is more recent than 89 days ago | ||
SELECT | ||
a.activity_datetime AS activity_date, | ||
a.gclid, | ||
a.conversion_name | ||
FROM | ||
`moz-fx-data-shared-prod.mozilla_org_derived.ga_desktop_conversions_v1` a | ||
JOIN | ||
all_clicks_not_originating_in_europe b | ||
ON a.gclid = b.gclid | ||
WHERE | ||
a.activity_date >= DATE_SUB(CURRENT_DATE, INTERVAL 89 DAY) | ||
AND b.first_session_date >= DATE_SUB(current_date, INTERVAL 89 day) |
815a075
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integration report for "Create new view for desktop conversion events (#6309)"
sql.diff
Click to expand!
Link to full diff