-
Notifications
You must be signed in to change notification settings - Fork 4
/
51_events.view.lkml
187 lines (159 loc) · 4.38 KB
/
51_events.view.lkml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
view: events {
sql_table_name: events ;;
dimension: event_id {
type: number
primary_key: yes
sql: ${TABLE}.id ;;
}
dimension: session_id {
type: number
hidden: yes
sql: ${TABLE}.session_id ;;
}
dimension: ip {
label: "IP Address"
view_label: "Visitors"
sql: ${TABLE}.ip_address ;;
}
dimension: user_id {
sql: ${TABLE}.user_id ;;
}
dimension_group: event {
type: time
# timeframes: [time, date, hour, time_of_day, hour_of_day, week, day_of_week_index, day_of_week]
sql: ${TABLE}.created_at ;;
}
dimension: sequence_number {
type: number
description: "Within a given session, what order did the events take place in? 1=First, 2=Second, etc"
sql: ${TABLE}.sequence_number ;;
}
dimension: is_entry_event {
type: yesno
description: "Yes indicates this was the entry point / landing page of the session"
sql: ${sequence_number} = 1 ;;
}
dimension: is_exit_event {
type: yesno
label: "UTM Source"
sql: ${sequence_number} = ${sessions.number_of_events_in_session} ;;
description: "Yes indicates this was the exit point / bounce page of the session"
}
measure: count_bounces {
type: count
description: "Count of events where those events were the bounce page for the session"
filters: {
field: is_exit_event
value: "Yes"
}
}
measure: bounce_rate {
type: number
value_format_name: percent_2
description: "Percent of events where those events were the bounce page for the session, out of all events"
sql: ${count_bounces}*1.0 / nullif(${count}*1.0,0) ;;
}
dimension: full_page_url {
sql: ${TABLE}.uri ;;
}
dimension: viewed_product_id {
type: number
sql: CASE
WHEN ${event_type} = 'Product' THEN right(${full_page_url},length(${full_page_url})-9)
END
;;
}
dimension: event_type {
sql: ${TABLE}.event_type ;;
}
dimension: funnel_step {
description: "Login -> Browse -> Add to Cart -> Checkout"
sql: CASE
WHEN ${event_type} IN ('Login', 'Home') THEN '(1) Land'
WHEN ${event_type} IN ('Category', 'Brand') THEN '(2) Browse Inventory'
WHEN ${event_type} = 'Product' THEN '(3) View Product'
WHEN ${event_type} = 'Cart' THEN '(4) Add Item to Cart'
WHEN ${event_type} = 'Purchase' THEN '(5) Purchase'
END
;;
}
measure: unique_visitors {
type: count_distinct
description: "Uniqueness determined by IP Address and User Login"
view_label: "Visitors"
sql: ${ip} ;;
drill_fields: [visitors*]
}
dimension: location {
type: location
view_label: "Visitors"
sql_latitude: ${TABLE}.latitude ;;
sql_longitude: ${TABLE}.longitude ;;
}
dimension: approx_location {
type: location
view_label: "Visitors"
sql_latitude: round(${TABLE}.latitude,1) ;;
sql_longitude: round(${TABLE}.longitude,1) ;;
}
dimension: has_user_id {
type: yesno
view_label: "Visitors"
description: "Did the visitor sign in as a website user?"
sql: ${users.id} > 0 ;;
}
dimension: browser {
view_label: "Visitors"
sql: ${TABLE}.browser ;;
}
dimension: os {
label: "Operating System"
view_label: "Visitors"
sql: ${TABLE}.os ;;
}
measure: count {
type: count
drill_fields: [simple_page_info*]
}
measure: sessions_count {
type: count_distinct
sql: ${session_id} ;;
}
measure: count_m {
label: "Count (MM)"
type: number
hidden: yes
sql: ${count}/1000000.0 ;;
drill_fields: [simple_page_info*]
value_format: "#.### \"M\""
}
measure: unique_visitors_m {
label: "Unique Visitors (MM)"
view_label: "Visitors"
type: number
sql: count (distinct ${ip}) / 1000000.0 ;;
description: "Uniqueness determined by IP Address and User Login"
value_format: "#.### \"M\""
hidden: yes
drill_fields: [visitors*]
}
measure: unique_visitors_k {
label: "Unique Visitors (k)"
view_label: "Visitors"
type: number
hidden: yes
description: "Uniqueness determined by IP Address and User Login"
sql: count (distinct ${ip}) / 1000.0 ;;
value_format: "#.### \"k\""
drill_fields: [visitors*]
}
set: simple_page_info {
fields: [event_id, event_time, event_type,
# - os
# - browser
full_page_url, user_id, funnel_step]
}
set: visitors {
fields: [ip, os, browser, user_id, count]
}
}