forked from llooker/google_ga360
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ga_customize.view.lkml
160 lines (113 loc) · 4.12 KB
/
ga_customize.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
include: "ga_block.view.lkml"
explore: ga_sessions_block {
extends: [ga_sessions_base]
extension: required
always_filter: {
filters: {
field: ga_sessions.partition_date
value: "7 days ago for 7 days"
## Partition Date should always be set to a recent date to avoid runaway queries
}
}
}
view: ga_sessions {
extends: [ga_sessions_base]
# The SQL_TABLE_NAME must be replaced here for date partitioned queries to work properly. There are several
# variations of sql_table_name patterns depending on the number of Properties (i.e. websites) being used.
# SCENARIO 1: Only one property
sql_table_name: `ga360.sessions_*` ;;
# SCENARIO 2: Multiple properties. The property will dynamically look at the selected dataset using a filter.
# sql_table_name: {% assign prop = ga_sessions.website_selector._sql %}
# {% if prop contains 'Website1' %} `project.dataset.ga_sessions_*`
# {% elsif prop contains 'Website2' %} `project.dataset.ga_sessions_*`
# {% elsif prop contains 'Website3' %} `project.dataset.ga_sessions_*`
# {% endif %}
# ;;
# filter: website_picker {
# suggestions: ["Website1","Website2", "Website3"]
# }
# dimension: website_selector {
# type: string
# hidden: no
# sql: {% parameter website_picker %} ;;
# }
# SCENARIO 3: Multiple properties. The property will dynamically look at the selected dataset. If using this pattern, change the partition_date definition in the ga_block file to type: date_time (no sql clause)
# sql_table_name: (SELECT *,'Property1' AS Property FROM `dataset_number.ga_sessions_*` WHERE {% condition partition_date %} TIMESTAMP(PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'^\d\d\d\d\d\d\d\d'))) {% endcondition %}
# UNION ALL SELECT *,'Property2' AS Property FROM `dataset_number2.ga_sessions_*` WHERE {% condition partition_date %} TIMESTAMP(PARSE_DATE('%Y%m%d', REGEXP_EXTRACT(_TABLE_SUFFIX,r'^\d\d\d\d\d\d\d\d'))) {% endcondition %});;
# dimension: property {
# sql: CASE WHEN ${TABLE}.property = 'Property1' THEN 'Name'
# WHEN ${TABLE}.property = 'Property2' THEN 'Name2'
# ELSE NULL END
# ;;
# }
# If you have custom dimensions on sessions, declare them here.
# dimension: custom_dimension_2 {
# sql: (SELECT value FROM UNNEST(${TABLE}.customdimensions) WHERE index=2) ;;
# }
# dimension: custom_dimension_2 {
# sql: (SELECT value FROM UNNEST(${TABLE}.customdimensions) WHERE index=2) ;;
# }
# dimension: custom_dimension_3 {
# sql: (SELECT value FROM UNNEST(${TABLE}.customdimensions) WHERE index=3) ;;
# }
}
view: geoNetwork {
extends: [geoNetwork_base]
}
view: totals {
extends: [totals_base]
}
view: trafficSource {
extends: [trafficSource_base]
}
view: device {
extends: [device_base]
}
view: hits {
extends: [hits_base]
}
view: hits_page {
extends: [hits_page_base]
}
# -- Ecommerce Fields
view: hits_transaction {
#extends: [hits_transaction_base] # Comment out to remove fields
}
view: hits_item {
#extends: [hits_item_base]
}
# -- Advertising Fields
view: adwordsClickInfo {
#extends: [adwordsClickInfo_base]
}
view: hits_publisher {
#extends: [hits_publisher_base] # Comment out this line to remove fields
}
# We only want some of the interaction fields.
view: hits_social {
extends: [hits_social_base]
dimension: socialInteractionNetwork {hidden: yes}
dimension: socialInteractionAction {hidden: yes}
dimension: socialInteractions {hidden: yes}
dimension: socialInteractionTarget {hidden: yes}
#dimension: socialNetwork {hidden: yes}
dimension: uniqueSocialInteractions {hidden: yes}
#dimension: hasSocialSourceReferral {hidden: yes}
dimension: socialInteractionNetworkAction {hidden: yes}
}
view: hits_appInfo {
extends: [hits_appInfo_base]
}
view: hits_eventInfo {
extends: [hits_eventInfo_base]
dimension: play {
sql: ${eventAction} = "play" ;;
type: yesno
}
}
view: hits_customDimensions {
extends: [hits_customDimensions_base]
}
view: hits_customVariables {
extends: [hits_customVariables_base]
}