Skip to content

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
image image

Behavior dashboard

Before After
image image

How to set up and validate locally

  1. Follow these instructions to set up Product Analytics in GDK.
  2. Onboard Product Analytics by setting up the feature at Project > Analytics > Analytics dashboards.
  3. Ensure you have collected some page view events.
  4. Visit the Behaviour dashboard at Project > Analytics > Analytics dashboards > Behaviour.
  5. Verify that you don't get any 0 values.
  6. Return to the analytics dashboard page.
  7. Click the Visualization designer button.
  8. Create a new visualization using the Page Views metric.
  9. Validate the visualizations don't show 0 values and the generated query includes the filter.

Related to #429820 (closed)

Edited by Robert Hunt

Merge request reports