Fix zero page view counts in behavior analytics dashboard
What does this MR do and why?
This MR adds a filter to limit pageViewsCount
queries to only page_view
events. We need this filter because under the hood, Cube adds the following SQL:
count(
CASE
WHEN (`tracked_events`.eventName = 'page_view') THEN `tracked_events`.event_id
END
) `tracked_events__page_views_count`
This is added to the select query, and in the event that the event isn't a page_view
tracked_events__page_views_count
will be set to 0
. Hence, the erroneous values at the end of the top pages visualization. It is picking up on non-page view events.
To be consistent with custom events, I've also updated it to use eventName
over event
as for built-in event types like page_view
both are the exact same value, whilst for custom events, only eventName
is populated with something meaningful.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Visualization designer
Before | After |
---|---|
Behavior dashboard
Before | After |
---|---|
How to set up and validate locally
- Follow these instructions to set up Product Analytics in GDK.
- Onboard
Product Analytics
by setting up the feature at Project > Analytics > Analytics dashboards. - Ensure you have collected some page view events.
- Visit the Behaviour dashboard at Project > Analytics > Analytics dashboards > Behaviour.
- Verify that you don't get any
0
values. - Return to the analytics dashboard page.
- Click the Visualization designer button.
- Create a new visualization using the
Page Views
metric. - Validate the visualizations don't show
0
values and the generated query includes the filter.
Related to #429820 (closed)