2022-10-11 01:57:18 +05:30
---
stage: Analyze
group: Product Analytics
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2022-10-11 01:57:18 +05:30
---
2023-01-13 00:05:48 +05:30
# Product analytics API **(ULTIMATE)**
2022-10-11 01:57:18 +05:30
2023-05-27 22:25:52 +05:30
> - Introduced in GitLab 15.4 [with a flag](../administration/feature_flags.md) named `cube_api_proxy`. Disabled by default.
> - `cube_api_proxy` removed and replaced with `product_analytics_internal_preview` in GitLab 15.10.
2023-06-20 00:43:36 +05:30
> - `product_analytics_internal_preview` replaced with `product_analytics_dashboards` in GitLab 15.11.
2022-10-11 01:57:18 +05:30
FLAG:
On self-managed GitLab, by default this feature is not available. To make it available per project or for your entire instance, ask an administrator to [enable the feature flag ](../administration/feature_flags.md ) named `cube_api_proxy` .
On GitLab.com, this feature is not available.
This feature is not ready for production use.
NOTE:
Make sure to define the `cube_api_base_url` and `cube_api_key` application settings first using [the API ](settings.md ).
2023-03-04 22:38:38 +05:30
## Send query request to Cube
2022-10-11 01:57:18 +05:30
Generate an access token that can be used to query the Cube API. For example:
```plaintext
2022-11-25 23:54:43 +05:30
POST /projects/:id/product_analytics/request/load
2023-03-04 22:38:38 +05:30
POST /projects/:id/product_analytics/request/dry-run
2022-10-11 01:57:18 +05:30
```
2023-04-23 21:23:45 +05:30
| Attribute | Type | Required | Description |
|-----------------|------------------| -------- |---------------------------------------------------------------------------------------------|
| `id` | integer | yes | The ID of a project that the current user has read access to. |
| `include_token` | boolean | no | Whether to include the access token in the response. (Only required for funnel generation.) |
2022-10-11 01:57:18 +05:30
### Request body
2023-03-04 22:38:38 +05:30
The body of the load request must be a valid Cube query.
2022-10-11 01:57:18 +05:30
2023-04-23 21:23:45 +05:30
NOTE:
When measuring `TrackedEvents` , you must use `TrackedEvents.*` for `dimensions` and `timeDimensions` . The same rule applies when measuring `Sessions` .
#### Tracked events example
2022-10-11 01:57:18 +05:30
```json
{
"query": {
"measures": [
2023-04-23 21:23:45 +05:30
"TrackedEvents.count"
2022-10-11 01:57:18 +05:30
],
"timeDimensions": [
{
2023-04-23 21:23:45 +05:30
"dimension": "TrackedEvents.utcTime",
2022-10-11 01:57:18 +05:30
"dateRange": "This week"
}
],
"order": [
[
2023-04-23 21:23:45 +05:30
"TrackedEvents.count",
2022-10-11 01:57:18 +05:30
"desc"
],
[
2023-04-23 21:23:45 +05:30
"TrackedEvents.docPath",
2022-10-11 01:57:18 +05:30
"desc"
],
[
2023-04-23 21:23:45 +05:30
"TrackedEvents.utcTime",
2022-10-11 01:57:18 +05:30
"asc"
]
],
"dimensions": [
2023-04-23 21:23:45 +05:30
"TrackedEvents.docPath"
2022-10-11 01:57:18 +05:30
],
"limit": 23
2022-11-25 23:54:43 +05:30
},
"queryType": "multi"
2022-10-11 01:57:18 +05:30
}
```
2023-03-04 22:38:38 +05:30
2023-04-23 21:23:45 +05:30
#### Sessions example
```json
{
"query": {
"measures": [
"Sessions.count"
],
"timeDimensions": [
{
"dimension": "Sessions.startAt",
"granularity": "day"
}
],
"order": {
"Sessions.startAt": "asc"
},
"limit": 100
},
"queryType": "multi"
}
```
2023-03-04 22:38:38 +05:30
## Send metadata request to Cube
Return Cube Metadata for the Analytics data. For example:
```plaintext
GET /projects/:id/product_analytics/request/meta
```
| Attribute | Type | Required | Description |
| --------- |------------------| -------- |---------------------------------------------------------------|
| `id` | integer | yes | The ID of a project that the current user has read access to. |
2023-04-23 21:23:45 +05:30
## List a project's funnels
List all funnels for a project. For example:
```plaintext
GET /projects/:id/product_analytics/funnels
```
| Attribute | Type | Required | Description |
| --------- |------------------| -------- |--------------------------------------------------------------------|
| `id` | integer | yes | The ID of a project that the current user has the Developer role for. |