-
Notifications
You must be signed in to change notification settings - Fork 31
/
f_tracker.sql
147 lines (122 loc) · 2.51 KB
/
f_tracker.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
{{
config (
materialized='table',
order_by=["dt", "account_service"]
)
}}
-- EVENTS
SELECT
dt
, event_id
, user_type
-- ACCOUNTS
, account_id
, account_caption
, account_service
, account_enabled
, account_status
, account_interval_start
, account_interval_end
-- SITES
, sites_domain
, sites_description
-- TRAFFIC
, traffic_grouping
, traffic_source
, traffic_medium
, traffic_campaign
, traffic_content
, traffic_keyword
, traffic_landing_page
-- DEVICES
, device_category
, device_browser
, device_browser_version
, device_os
, device_os_version
-- CAMPAIGNS
, NULL AS campaign_id
, NULL AS campaign_name
, NULL AS campaign_state
-- CLIENTS
, client_id
, client_phone
, client_email
-- LOCATIONS
, location_country_iso
, location_country
, location_region_iso
, location_region
, location_city
-- GOALS
, goal_id
, goal_name
-- MEASURES
, NULL AS impressions
, NULL AS clicks
, NULL AS cost
, sessions
, bounces
, pageviews
, duration
, goal_completions
, goal_value
FROM {{ ref('f_ga_events') }}
UNION ALL
SELECT
dt
, cost_id
, NULL AS user_type
-- ACCOUNTS
, account_id
, account_caption
, account_service
, account_enabled
, account_status
, account_interval_start
, account_interval_end
-- SITES
, sites_domain
, sites_description
-- TRAFFIC
, traffic_grouping
, traffic_source
, traffic_medium
, traffic_campaign
, traffic_content
, traffic_keyword
, traffic_landing_page
-- DEVICES
, device AS device_category
, NULL AS device_browser
, NULL AS device_browser_version
, NULL AS device_os
, NULL AS device_os_version
-- CAMPAIGNS
, campaign_id
, campaign_name
, campaign_state
-- CLIENTS
, NULL AS client_id
, NULL AS client_phone
, NULL AS client_email
-- LOCATIONS
, NULL AS location_country_iso
, NULL AS location_country
, NULL AS location_region_iso
, NULL AS location_region
, NULL AS location_city
-- GOALS
, NULL AS goal_id
, NULL AS goal_name
-- MEASURES
, impressions
, clicks
, cost
, NULL AS sessions
, NULL AS bounces
, NULL AS pageviews
, NULL AS duration
, NULL AS goal_completions
, NULL AS goal_value
FROM {{ ref('f_costs') }}