@@ -5,13 +5,15 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
55 top_pages : {
66 table : Analytics . events ,
77 fields : [
8- "trimRight(path(path), '/') as name" ,
8+ "CASE WHEN trimRight(path(path), '/') = '' THEN '/' ELSE trimRight(path(path), '/') END as name" ,
99 'COUNT(*) as pageviews' ,
1010 'COUNT(DISTINCT anonymous_id) as visitors' ,
1111 'ROUND((COUNT(*) / SUM(COUNT(*)) OVER()) * 100, 2) as percentage' ,
1212 ] ,
13- where : [ "event_name = 'screen_view'" , "path != ''" ] ,
14- groupBy : [ "trimRight(path(path), '/')" ] ,
13+ where : [ "event_name = 'screen_view'" ] ,
14+ groupBy : [
15+ "CASE WHEN trimRight(path(path), '/') = '' THEN '/' ELSE trimRight(path(path), '/') END" ,
16+ ] ,
1517 orderBy : 'pageviews DESC' ,
1618 limit : 100 ,
1719 timeField : 'time' ,
@@ -27,7 +29,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
2729 'COUNT(DISTINCT anonymous_id) as visitors' ,
2830 'ROUND((COUNT(*) / SUM(COUNT(*)) OVER()) * 100, 2) as percentage' ,
2931 ] ,
30- where : [ "event_name = 'screen_view'" , "path != ''" ] ,
32+ where : [ "event_name = 'screen_view'" ] ,
3133 groupBy : [ 'entry_page' ] ,
3234 orderBy : 'pageviews DESC' ,
3335 limit : 100 ,
@@ -48,15 +50,14 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
4850 SELECT
4951 session_id,
5052 anonymous_id,
51- trimRight(path(path), '/') as entry_page,
53+ CASE WHEN trimRight(path(path), '/') = '' THEN '/' ELSE trimRight(path(path), '/') END as entry_page,
5254 time as entry_time,
5355 ROW_NUMBER() OVER (PARTITION BY session_id ORDER BY time) as page_rank
5456 FROM analytics.events
5557 WHERE client_id = {websiteId:String}
5658 AND time >= parseDateTimeBestEffort({startDate:String})
5759 AND time <= parseDateTimeBestEffort({endDate:String})
5860 AND event_name = 'screen_view'
59- AND path != ''
6061 )
6162 SELECT
6263 entry_page as name,
@@ -87,7 +88,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
8788 'COUNT(DISTINCT anonymous_id) as visitors' ,
8889 'ROUND((COUNT(DISTINCT session_id) / SUM(COUNT(DISTINCT session_id)) OVER()) * 100, 2) as percentage' ,
8990 ] ,
90- where : [ "event_name = 'screen_view'" , "path != ''" ] ,
91+ where : [ "event_name = 'screen_view'" ] ,
9192 groupBy : [ 'path' ] ,
9293 orderBy : 'pageviews DESC' ,
9394 limit : 100 ,
@@ -113,12 +114,11 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
113114 AND time >= parseDateTimeBestEffort({startDate:String})
114115 AND time <= parseDateTimeBestEffort({endDate:String})
115116 AND event_name = 'screen_view'
116- AND path != ''
117117 GROUP BY session_id
118118 ),
119119 exit_pages AS (
120120 SELECT
121- trimRight(path(e.path), '/') as path,
121+ CASE WHEN trimRight(path(e.path), '/') = '' THEN '/' ELSE trimRight(path(e.path), '/') END as path,
122122 e.session_id,
123123 e.anonymous_id
124124 FROM analytics.events e
@@ -127,7 +127,6 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
127127 AND e.time >= parseDateTimeBestEffort({startDate:String})
128128 AND e.time <= parseDateTimeBestEffort({endDate:String})
129129 AND e.event_name = 'screen_view'
130- AND e.path != ''
131130 )
132131 SELECT
133132 path as name,
@@ -152,13 +151,15 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
152151 page_performance : {
153152 table : Analytics . events ,
154153 fields : [
155- "trimRight(path(path), '/') as name" ,
154+ "CASE WHEN trimRight(path(path), '/') = '' THEN '/' ELSE trimRight(path(path), '/') END as name" ,
156155 'COUNT(*) as pageviews' ,
157156 'ROUND(AVG(CASE WHEN time_on_page > 0 THEN time_on_page / 1000 ELSE NULL END), 2) as avg_time_on_page' ,
158157 'COUNT(DISTINCT anonymous_id) as visitors' ,
159158 ] ,
160- where : [ "event_name = 'screen_view'" , "path != ''" ] ,
161- groupBy : [ "trimRight(path(path), '/')" ] ,
159+ where : [ "event_name = 'screen_view'" ] ,
160+ groupBy : [
161+ "CASE WHEN trimRight(path(path), '/') = '' THEN '/' ELSE trimRight(path(path), '/') END" ,
162+ ] ,
162163 orderBy : 'pageviews DESC' ,
163164 limit : 100 ,
164165 timeField : 'time' ,
0 commit comments