-
Notifications
You must be signed in to change notification settings - Fork 31
/
int_ga_goals_facts.sql
81 lines (71 loc) · 2.82 KB
/
int_ga_goals_facts.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
SELECT
facts.dt AS dt
, {{ dbt_utils.surrogate_key([
'facts.dt'
, 'goals.goal_id'
, 'facts.account_id'
, 'facts.sites_id'
, 'facts.clientids_id'
, 'facts.devices_id'
, 'facts.traffic_id'
, 'facts.locations_id'
]) }} AS event_id
-- GOALS
--, facts.goals_id
, goals.goal_id AS goal_id
, goals.name AS goal_name
, goals.active AS goal_active
-- ACCOUNTS
, facts.account_id AS account_id
, accounts.caption AS account_caption
, accounts.service AS account_service
, accounts.enabled AS account_enabled
, accounts.status AS account_status
, accounts.interval_start AS account_interval_start
, accounts.interval_end AS account_interval_end
-- SITES
--, facts.sites_id AS sites_id
, sites.domain AS sites_domain
, sites.description AS sites_description
-- CLIENTS
--, facts.clientids_id AS clientids_id
, clients.clientid AS client_id
, clients.userid AS client_userid
, clients.phone AS client_phone
, clients.email AS client_email
-- DEVICES
--, facts.devices_id AS devices_id
, devices.category AS device_category
, devices.browser AS device_browser
, devices.browser_version AS device_browser_version
, devices.os AS device_os
, devices.os_version AS device_os_version
-- TRAFFIC
--, facts.traffic_id AS traffic_id
, traffic.grouping AS traffic_grouping
, traffic.source AS traffic_source
, traffic.medium AS traffic_medium
, traffic.campaign AS traffic_campaign
, traffic.content AS traffic_content
, traffic.keyword AS traffic_keyword
, traffic.landing_page AS traffic_landing_page
-- LOCATIONS
--, facts.locations_id AS locations_id
, locations.country_iso AS location_country_iso
, locations.country AS location_country
, locations.region_iso AS location_region_iso
, locations.region AS location_region
, locations.city AS location_city
, locations.latitude AS location_latitude
, locations.longitude AS location_longitude
-- MEASURES
, facts.completions AS goal_completions
, facts.goal_value AS goal_value
FROM {{ ref('stg_ga_goals_facts') }} AS facts
LEFT JOIN {{ ref('stg_general_accounts') }} AS accounts ON accounts.account_id = facts.account_id
LEFT JOIN {{ ref('stg_general_sites') }} AS sites ON sites.id = facts.sites_id
LEFT JOIN {{ ref('stg_general_clientids') }} AS clients ON facts.clientids_id = clients.id
LEFT JOIN {{ ref('stg_ga_devices') }} AS devices ON devices.id = facts.devices_id
LEFT JOIN {{ ref('stg_general_traffic') }} AS traffic ON traffic.id = facts.traffic_id
LEFT JOIN {{ ref('stg_general_locations') }} AS locations ON locations.id = facts.locations_id
LEFT JOIN {{ ref('stg_ga_goals') }} AS goals ON goals.id = facts.goals_id