# Google Analytics Data V1alpha Client - Class CohortSpec (0.24.0)

0.24.0 (latest) 0.23.3 0.22.3 0.21.1 0.20.1 0.19.0 0.18.0 0.17.1 0.16.4 0.14.0 0.13.0 0.12.0 0.11.2 0.10.1 0.9.5

> [!WARNING]
> **Beta**
>
>
> This library is covered by the [Pre-GA Offerings Terms](https://docs.cloud.google.com/terms/service-terms#1)
> of the Terms of Service. Pre-GA libraries might have limited support,
> and changes to pre-GA libraries might not be compatible with other pre-GA versions.
> For more information, see the
> [launch stage descriptions](https://docs.cloud.google.com/products#product-launch-stages).

Reference documentation and code samples for the Google Analytics Data V1alpha Client class CohortSpec.

The specification of cohorts for a cohort report.

Cohort reports create a time series of user retention for the cohort. For
example, you could select the cohort of users that were acquired in the first
week of September and follow that cohort for the next six weeks. Selecting
the users acquired in the first week of September cohort is specified in the
`cohort` object. Following that cohort for the next six weeks is specified in
the `cohortsRange` object.
For examples, see [Cohort Report
Examples](https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#cohort_report_examples).
The report response could show a weekly time series where say your app has
retained 60% of this cohort after three weeks and 25% of this cohort after
six weeks. These two percentages can be calculated by the metric
`cohortActiveUsers/cohortTotalUsers` and will be separate rows in the report.

Generated from protobuf message `google.analytics.data.v1alpha.CohortSpec`

## Namespace

Google \\ Analytics \\ Data \\ V1alpha

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ cohorts` | `array<https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.Cohort>` Defines the selection criteria to group users into cohorts. Most cohort reports define only a single cohort. If multiple cohorts are specified, each cohort can be recognized in the report by their name. |
| `↳ cohorts_range` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.CohortsRange` Cohort reports follow cohorts over an extended reporting date range. This range specifies an offset duration to follow the cohorts over. |
| `↳ cohort_report_settings` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.CohortReportSettings` Optional settings for a cohort report. |

### getCohorts

Defines the selection criteria to group users into cohorts.

Most cohort reports define only a single cohort. If multiple cohorts are
specified, each cohort can be recognized in the report by their name.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://protobuf.dev/reference/php/api-docs/Google/Protobuf/RepeatedField<https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.Cohort>` |   |

### setCohorts

Defines the selection criteria to group users into cohorts.

Most cohort reports define only a single cohort. If multiple cohorts are
specified, each cohort can be recognized in the report by their name.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `array<https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.Cohort>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCohortsRange

Cohort reports follow cohorts over an extended reporting date range. This
range specifies an offset duration to follow the cohorts over.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.CohortsRange|null` |   |

### hasCohortsRange

### clearCohortsRange

### setCohortsRange

Cohort reports follow cohorts over an extended reporting date range. This
range specifies an offset duration to follow the cohorts over.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.CohortsRange` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCohortReportSettings

Optional settings for a cohort report.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.CohortReportSettings|null` |   |

### hasCohortReportSettings

### clearCohortReportSettings

### setCohortReportSettings

Optional settings for a cohort report.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.CohortReportSettings` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |