forked from llooker/demo_segment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
5_session_track_facts.view.lkml
112 lines (92 loc) · 2.28 KB
/
5_session_track_facts.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
# Facts about a particular Session.
view: session_trk_facts {
derived_table: {
sql_trigger_value: select count(*) from ${track_facts.SQL_TABLE_NAME} ;;
sortkeys: ["session_id"]
distribution: "session_id"
sql: SELECT s.session_id
, MAX(map.received_at) AS ended_at
, count(distinct map.event_id) AS num_pvs
, count(case when map.event = 'signed_up' then event_id else null end) as cnt_signed_up
, count(case when map.event = 'logged_in' then event_id else null end) as cnt_logged_in
, count(case when map.event = 'made_signup_search' then event_id else null end) as cnt_made_signup_search
, count(case when map.event = 'made_update_search' then event_id else null end) as cnt_made_update_search
FROM ${sessions_trk.SQL_TABLE_NAME} AS s
LEFT JOIN ${track_facts.SQL_TABLE_NAME} as map on map.session_id = s.session_id
GROUP BY 1
;;
}
dimension: session_id {
hidden: yes
primary_key: yes
sql: ${TABLE}.session_id ;;
}
dimension_group: ended_at {
type: time
timeframes: [time, date, week, month]
sql: ${TABLE}.ended_at ;;
}
dimension: number_events {
type: number
sql: ${TABLE}.num_pvs ;;
}
dimension: is_bounced_session {
type: yesno
sql: ${number_events} = 1 ;;
}
dimension: app_loaded {
type: yesno
sql: ${TABLE}.cnt_app_loaded > 0 ;;
}
dimension: login {
type: yesno
sql: ${TABLE}.cnt_login > 0 ;;
}
dimension: subscribed_to_blog {
type: yesno
sql: ${TABLE}.cnt_subscribed_to_blog > 0 ;;
}
dimension: signup {
type: yesno
sql: ${TABLE}.cnt_signup > 0 ;;
}
dimension: num_pvs {
type: number
sql: ${TABLE}.num_pvs ;;
}
measure: count_events {
type: sum
sql: ${number_events} ;;
}
measure: count_app_loaded {
type: count
filters: {
field: app_loaded
value: "yes"
}
}
measure: count_login {
type: count
filters: {
field: login
value: "yes"
}
}
measure: count_subscribed_to_blog {
type: count
filters: {
field: subscribed_to_blog
value: "yes"
}
}
measure: count_signup {
type: count
filters: {
field: signup
value: "yes"
}
}
set: detail {
fields: [ended_at_date, num_pvs]
}
}