Show distinct set of URLs for pages listed in the Behavior Top Pages panel
For path fragments, that is explored as a separate enhancement in Update top pages panel under the behavior dashb... (#420898)
Summary
In implementing Deeplink URLs presented as Top Pages in the Beh... (#406815 - closed), we ended up breaking the "Top pages" panel in the Behavior dashboard, splitting out results because the deep links were including page fragments, showing the same URL as multiple line items under "Top pages".
Problem
This is confusing to a user because if you expect your homepage, e.g. /
, to be the top page, it shouldn't show up multiple times in the visualization.
Proposal
Use a different dimension when deep-linking URLs in the Top Pages visualization, such that each URL shows up only once, resulting in a list of distinct pages that are sorted from most page views to fewest.
Example
Page URLPath | Views |
---|---|
content/voice-and-tone |
180 |
other-page/ |
75 |
/ |
10 |
Implementation plan
Update CubeJS TrackedEvents.js
schema (also in analytics-stack):
- add new
baseUrl
dimension which we can combine withpath
to create a link href:
baseUrl: {
sql: `CONCAT(page_urlscheme, '://', page_urlhost, IF(page_urlport IS NOT NULL AND page_urlport != '', ':', ''), page_urlport)`,
type: `string`,
},
Modify top_pages.yml
visualization:
- query for
baseUrl
dimension instead ofpageUrl
(this means results will no longer be split by full URL, and will be split by path + baseUrl. The same path over different baseUrl would result in separate rows in the dashboard, which seems correct) - links href becomes array of
baseUrl
andpageUrlpath
Update JSON schema:
- allow
href
to be an array of multiple fields, e.g.
"href": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
Update cube_analytics.js
:
- modify link dimensions code to accept an array of dimensions as well as a single dimension
- concat multiple dimensions to create an href
Update tests, and docs.