Product analytics

Tier: Ultimate Offering: GitLab.com, Self-managed Status: Beta
History
  • Introduced in GitLab 15.4 as an experiment feature with a flag named cube_api_proxy. Disabled by default.
  • cube_api_proxy changed to reference only the product analytics API in GitLab 15.6.
  • cube_api_proxy removed and replaced with product_analytics_internal_preview in GitLab 15.10.
  • product_analytics_internal_preview replaced with product_analytics_dashboards in GitLab 15.11.
  • Snowplow integration introduced in GitLab 15.11 with a flag named product_analytics_snowplow_support. Disabled by default.
  • Snowplow integration feature flag product_analytics_snowplow_support removed in GitLab 16.4.
  • Moved from GitLab self-managed to GitLab.com in 16.7.
  • Enabled in GitLab 16.7 as a beta feature.
  • product_analytics_dashboards enabled by default in GitLab 16.11.
  • Enabled on self-managed and GitLab Dedicated in GitLab 16.11.
  • Feature flag product_analytics_dashboards removed in GitLab 17.1.
  • Changed to beta and feature flag product_analytics_admin_settings added in GitLab 17.5.
  • Changed to beta and feature flag product_analytics_features added in GitLab 17.5.
The availability of this feature is controlled by a feature flag. For more information, see the history. This feature is not ready for production use.

The product analytics feature empowers you to track user behavior and gain insights into how your applications are used and how users interact with your product. By using the data collected with product analytics in GitLab, you can better understand your users, identify friction points in funnels, make data-driven product decisions, and ultimately build better products that drive user engagement and business growth.

For an overview of the product analytics setup and functionality, watch the Product Analytics walkthrough videos.

For more information about the vision and development of product analytics, see the group direction page. To leave feedback about product analytics bugs or functionality:

  • Comment on issue 391970.
  • Create an issue with the group::product analytics label.

How product analytics works

Product analytics uses the following tools:

  • Snowplow - A developer-first engine for collecting behavioral data and passing it through to ClickHouse.
  • ClickHouse - A database suited to store, query, and retrieve analytical data.
  • Cube - A universal semantic layer that provides an API to run queries against the data stored in ClickHouse.

The following diagram illustrates the product analytics flow:

%%{init: { "fontFamily": "GitLab Sans" }}%% flowchart TB accTitle: Product Analytics flow accDescr: How data is collected, processed, and visualized in dashboards. subgraph Event collection A([SDK]) --Send user data--> B[Snowplow Collector] B --Pass data--> C[Snowplow Enricher] end subgraph Data warehouse C --Transform and enrich data--> D([ClickHouse]) end subgraph Data visualization F([Dashboards with panels/visualizations]) F --Request data--> G[Product Analytics API] G --Run Cube queries with pre-aggregations--> H[Cube] H --Get data--> D D --Return results--> H H --Transform data to be rendered--> G G --Return data--> F end

Enable product analytics

History
  • Introduced in GitLab 15.6 with a flag named cube_api_proxy. Disabled by default.
  • Moved behind a flag named product_analytics_admin_settings in GitLab 15.7. Disabled by default.
  • Feature flag cube_api_proxy removed and replaced with product_analytics_internal_preview in GitLab 15.10.
  • Feature flag product_analytics_internal_preview replaced with product_analytics_dashboards in GitLab 15.11.
  • Feature flag product_analytics_admin_settings enabled by default in GitLab 16.11.
  • Feature flag product_analytics_admin_settings removed in GitLab 17.1.

To track events in your project’s applications, you must enable and configure product analytics.

Product analytics provider

Your GitLab instance connects to a product analytics provider. A product analytics provider is the collection of services required to receive, process, store and query your analytics data.

GitLab-managed provider
Offering: GitLab.com

On GitLab.com you can use a GitLab-managed provider offered only in the Google Cloud Platform zone us-central-1. This service is offered only in beta.

If GitLab manages your product analytics provider, then your analytics data is retained for one year. You can request to delete your data at any time by contacting support.

Self-managed provider
History

Introduced in GitLab 16.0.

A self-managed product analytics provider is a deployed instance of the product analytics Helm charts.

On GitLab.com, the self-managed provider details are defined in project-level settings.

On GitLab self-managed and GitLab Dedicated, you must define the self-managed analytics provider in instance-level settings. If you need different providers for different projects, you can define additional analytics providers in project-level settings.

Instance-level settings

Offering: Self-managed, GitLab Dedicated

Prerequisites:

  • You must have administrator access for the instance.
note
These instance-level settings are required to enable product analytics on GitLab self-managed and GitLab Dedicated, and cascade to all projects by default.

To enable product analytics on your instance:

  1. On the left sidebar, at the bottom, select Admin.
  2. Select Settings > Analytics.
  3. Enter the configuration values.
  4. Select Save changes.

Project-level settings

If you want to have a product analytics instance with a different configuration for your project, you can override the instance-level settings defined by the administrator on a per-project basis.

Prerequisites:

  • You must have at least the Maintainer role for the project or group the project belongs to.
  • The project must be in a group namespace.
  1. On the left sidebar, select Search or go to and find your project.
  2. Select Settings > Analytics.
  3. Expand Data sources and enter the configuration values.
  4. Select Save changes.

Onboard a GitLab project

History
  • Minimum required role changed in GitLab 17.1.

Prerequisites:

  • You must have at least the Maintainer role for the project or group the project belongs to.

Onboarding a GitLab project means preparing it to receive events that are used for product analytics.

To onboard a project:

  1. On the left sidebar, select Search or go to and find your project.
  2. Select Analyze > Analytics dashboards.
  3. Under Product analytics, select Set up.

Then continue with the setup depending on the provider type.

GitLab-managed provider

Prerequisites:

  1. Select the I agree to event collection and processing in this region checkbox.
  2. Select Connect GitLab-managed provider.
  3. Remove already configured project-level settings for a self-managed provider:
    1. Select Go to analytics settings.
    2. Expand Data sources and remove the configuration values.
    3. Select Save changes.
    4. Select Analyze > Analytics dashboards.
    5. Under Product analytics, select Set up.
    6. Select Connect GitLab-managed provider.

Your instance is being created, and the project onboarded.

Self-managed provider
  1. Select Connect your own provider.
  2. Configure project-level settings for your self-managed provider:
    1. Select Go to analytics settings.
    2. Expand Data sources and enter the configuration values.
    3. Select Save changes.
    4. Select Analyze > Analytics dashboards.
    5. Under Product analytics, select Set up.
    6. Select Connect your own provider.

Your instance is being created, and the project onboarded.

Instrument your application

You can instrument code to collect data by using tracking SDKs.

Product analytics dashboards

History
  • Introduced in GitLab 15.5 with a flag named product_analytics_internal_preview. Disabled by default.

Product analytics dashboards are a subset of dashboards under Analytics dashboards.

Specifically, product analytics dashboards and visualizations use the cube_analytics data type. The cube_analytics data type connects to the Cube instance defined when product analytics was enabled. All filters and queries are sent to the Cube instance, and the returned data is processed by the product analytics data source to be rendered by the appropriate visualizations.

Data table visualizations from cube_analytics have an additional configuration option for rendering links. This option is an array of objects, each with text and href properties to specify the dimensions to be used in links. If href contains multiple dimensions, values are joined into a single URL. View an example.

Filling missing data

History
  • Introduced in GitLab 16.3 with a flag named product_analytics_dashboards. Disabled by default.

When exporting data or viewing dashboards, if there is no data for a given day, the missing data is autofilled with 0.

The autofill approach has both benefits and limitations.

  • Benefits:
    • The visualization’s day axis matches the selected date range, removing ambiguity about missing data.
    • Data exports have rows for the entire date range, making data analysis easier.
  • Limitations:
    • The day granularity must be used. All other granularities are not supported.
    • Only date ranges defined by the inDateRange filter are filled.
      • The date selector in the UI already uses this filter.
    • The filling of data ignores the query-defined limit. If you set a limit of 10 data points over 20 days, it returns 20 data points, with the missing data filled by 0. Issue 417231 proposes a solution to this limitation.

Funnel analysis

Use funnel analysis to understand the flow of users through your application, and where users drop out of a predefined flow (for example, a checkout process or ticket purchase).

Each project can define an unlimited number of funnels. Like dashboards, funnels are defined with the GitLab YAML schema and stored in the .gitlab/analytics/funnels/ directory of a project repository. If a repository has a custom dashboards pointer project that points to another repository, funnels must be defined in the pointer project.

Create a funnel dashboard

To create a funnel dashboard, you must first create a funnel definition file and a visualization. Each funnel must have a custom visualization defined for it. When funnel definitions and visualizations are ready, you can create a custom dashboard to visualize funnel analysis behavior.

Create a funnel definition

  1. In the .gitlab/analytics/ directory, create a directory named funnels.
  2. In the new .gitlab/analytics/funnels directory, create a funnel definition YAML file.

Funnel definitions must include the key seconds_to_convert and an array of steps.

Key Description
seconds_to_convert The number of seconds a user has to complete the funnel.
steps An array of funnel steps.

Each step must include the keys name, target, and action.

Key Description
name The name of the step. This should be a unique slug.
action The action performed. (Only pageview is supported.)
target The target of the step. (Because only pageview is supported, this should be a path.)

The following example defines a funnel that tracks users who completed a purchase within one hour by going through three target pages:

seconds_to_convert: 3600
steps:
  - name: view_page_1
    target: '/page1.html'
    action: 'pageview'
  - name: view_page_2
    target: '/page2.html'
    action: 'pageview'
  - name: view_page_3
    target: '/page3.html'
    action: 'pageview'

Create a funnel visualization

To create funnel visualizations, follow the steps for defining a chart visualization. Funnel visualizations support the measure count and the dimension step.

The following example defines a column chart that visualizes the number of users who reached different steps in a funnel:

version: 1
type: ColumnChart
data:
  type: cube_analytics
  query:
    measures:
      - FUNNEL_NAME.count
    dimensions:
      - FUNNEL_NAME.step
    limit: 100
    timezone: UTC
    timeDimensions: []
options:
  xAxis:
    name: Step
    type: category
  yAxis:
    name: Total
    type: value
note
The funnel name defined in the YAML definition is converted to a slug that can be referenced in visualization definitions. For example, the funnel name Successful Conversions is converted to successful_conversions.

Query a funnel

You can query the funnel data with the REST API. To do this, you can use the example query body below, where you need to replace FUNNEL_NAME with your funnel’s name.

note
The name of a funnel is generated from the filename of the funnel definition YAML file, by separating words with underscores and removing special characters. For example, for a funnel definition file in .gitlab/analytics/funnels/Successful Conversions.yaml the funnel name is successful_conversions. This funnel name can be referenced in visualization definitions.
note
The afterDate filter is not supported. Use beforeDate or inDateRange.
{
  "query": {
      "measures": [
        "FUNNEL_NAME.count"
      ],
      "order": {
        "FUNNEL_NAME.count": "desc"
      },
      "filters": [
        {
          "member": "FUNNEL_NAME.date",
          "operator": "beforeDate",
          "values": [
            "2023-02-01"
          ]
        }
      ],
      "dimensions": [
        "FUNNEL_NAME.step"
      ]
    }
}

Raw data export

Exporting the raw event data from the underlying storage engine can help you debug and create datasets for data analysis.

Because Cube acts as an abstraction layer between the raw data and the API, the exported raw data has some caveats:

  • Data is grouped by the selected dimensions. Therefore, the exported data might be incomplete, unless including both utcTime and userAnonymousId.
  • Data is by default limited to 10,000 rows, but you can increase the limit to maximum 50,000 rows. If your dataset has more than 50,000 rows, you must paginate through the results by using the limit and offset parameters.
  • Data is always returned in JSON format. If you need it in a different format, you need to convert the JSON to the required format using a scripting language of your choice.

Issue 391683 tracks efforts to implement a more scalable export solution.

Export raw data with Cube queries

You can query the raw data with the REST API, and convert the JSON output to any required format.

To export the raw data for a specific dimension, pass a list of dimensions to the dimensions key. For example, the following query outputs the raw data for the attributes listed:

POST /api/v4/projects/PROJECT_ID/product_analytics/request/load?queryType=multi

{
    "query":{
  "dimensions": [
    "TrackedEvents.docEncoding",
    "TrackedEvents.docHost",
    "TrackedEvents.docPath",
    "TrackedEvents.docSearch",
    "TrackedEvents.eventType",
    "TrackedEvents.localTzOffset",
    "TrackedEvents.pageTitle",
    "TrackedEvents.src",
    "TrackedEvents.utcTime",
    "TrackedEvents.vpSize"
  ],
  "order": {
    "TrackedEvents.apiKey": "asc"
  }
    }
}

If the request is successful, the returned JSON includes an array of rows of results.

View product analytics usage quota

History

Product analytics usage quota is calculated from the number of events received from instrumented applications.

To view product analytics usage quota:

  1. On the left sidebar, select Search or go to and find your group.
  2. Select Settings > Usage quota.
  3. Select the Product analytics tab.

The tab displays the monthly totals for the group and a breakdown of usage per project. The current month displays events counted to date.

The usage quota excludes projects that are not onboarded with product analytics.

Best practices

  • Define key metrics and goals from the start. Decide what questions you want to answer so you know how to use collected data.
  • Use event data from all stages of the user journey. This data provides a comprehensive view of the user experience.
  • Build dashboards aligned with team needs. Different teams need different data insights.
  • Review dashboards regularly. This way, you can verify customer outcomes, identify trends in data, and update visualizations.
  • Export raw data periodically. Dashboards provide only an overview of a subset of data, so you should export the data for a deeper analysis.

Troubleshooting

No events are collected

Check your instrumentation details, and make sure product analytics is enabled and set up correctly.

Access to product analytics is restricted

Check that you are connected to a product analytics provider.