# Google Analytics Data V1alpha Client - Class Cohort (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 Cohort.

Defines a cohort selection criteria. A cohort is a group of users who share
a common characteristic. For example, users with the same `firstSessionDate`
belong to the same cohort.

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

## Namespace

Google \\ Analytics \\ Data \\ V1alpha

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` Assigns a name to this cohort. The dimension `cohort` is valued to this name in a report response. If set, cannot begin with `cohort_` or `RESERVED_`. If not set, cohorts are named by their zero based index `cohort_0`, `cohort_1`, etc. |
| `↳ dimension` | `string` Dimension used by the cohort. Required and only supports `firstSessionDate`. |
| `↳ date_range` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.DateRange` The cohort selects users whose first touch date is between start date and end date defined in the `dateRange`. This `dateRange` does not specify the full date range of event data that is present in a cohort report. In a cohort report, this `dateRange` is extended by the granularity and offset present in the `cohortsRange`; event data for the extended reporting date range is present in a cohort report. In a cohort request, this `dateRange` is required and the `dateRanges` in the `RunReportRequest` or `RunPivotReportRequest` must be unspecified. This `dateRange` should generally be aligned with the cohort's granularity. If `CohortsRange` uses daily granularity, this `dateRange` can be a single day. If `CohortsRange` uses weekly granularity, this `dateRange` can be aligned to a week boundary, starting at Sunday and ending Saturday. If `CohortsRange` uses monthly granularity, this `dateRange` can be aligned to a month, starting at the first and ending on the last day of the month. |

### getName

Assigns a name to this cohort. The dimension `cohort` is valued to this
name in a report response. If set, cannot begin with `cohort_` or
`RESERVED_`. If not set, cohorts are named by their zero based index
`cohort_0`, `cohort_1`, etc.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setName

Assigns a name to this cohort. The dimension `cohort` is valued to this
name in a report response. If set, cannot begin with `cohort_` or
`RESERVED_`. If not set, cohorts are named by their zero based index
`cohort_0`, `cohort_1`, etc.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

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

### getDimension

Dimension used by the cohort. Required and only supports
`firstSessionDate`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setDimension

Dimension used by the cohort. Required and only supports
`firstSessionDate`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

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

### getDateRange

The cohort selects users whose first touch date is between start date and
end date defined in the `dateRange`. This `dateRange` does not specify the
full date range of event data that is present in a cohort report. In a
cohort report, this `dateRange` is extended by the granularity and offset
present in the `cohortsRange`; event data for the extended reporting date
range is present in a cohort report.

In a cohort request, this `dateRange` is required and the `dateRanges` in
the `RunReportRequest` or `RunPivotReportRequest` must be unspecified.
This `dateRange` should generally be aligned with the cohort's granularity.
If `CohortsRange` uses daily granularity, this `dateRange` can be a single
day. If `CohortsRange` uses weekly granularity, this `dateRange` can be
aligned to a week boundary, starting at Sunday and ending Saturday. If
`CohortsRange` uses monthly granularity, this `dateRange` can be aligned to
a month, starting at the first and ending on the last day of the month.

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

### hasDateRange

### clearDateRange

### setDateRange

The cohort selects users whose first touch date is between start date and
end date defined in the `dateRange`. This `dateRange` does not specify the
full date range of event data that is present in a cohort report. In a
cohort report, this `dateRange` is extended by the granularity and offset
present in the `cohortsRange`; event data for the extended reporting date
range is present in a cohort report.

In a cohort request, this `dateRange` is required and the `dateRanges` in
the `RunReportRequest` or `RunPivotReportRequest` must be unspecified.
This `dateRange` should generally be aligned with the cohort's granularity.
If `CohortsRange` uses daily granularity, this `dateRange` can be a single
day. If `CohortsRange` uses weekly granularity, this `dateRange` can be
aligned to a week boundary, starting at Sunday and ending Saturday. If
`CohortsRange` uses monthly granularity, this `dateRange` can be aligned to
a month, starting at the first and ending on the last day of the month.

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

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