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

A segment is a subset of your Analytics data. For example, of your entire set
of users, one segment might be users from a particular country or city.

Another segment might be users who purchase a particular line of products or
who visit a specific part of your site or trigger certain events in your app.
To learn more, see [Segment
Builder](https://support.google.com/analytics/answer/9304353).

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

## Namespace

Google \\ Analytics \\ Data \\ V1alpha

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ name` | `string` The name for this segment. If unspecified, segments are named "Segment". This name defines string value returned by the `segment` dimension. The `segment` dimension prefixes segment names by the 1-based index number of the segment in the request (for example "1. Segment", "2. Segment", etc.). |
| `↳ user_segment` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.UserSegment` User segments are subsets of users who engaged with your site or app. |
| `↳ session_segment` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.SessionSegment` Session segments are subsets of the sessions that occurred on your site or app. |
| `↳ event_segment` | `https://docs.cloud.google.com/php/docs/reference/analytics-data/latest/V1alpha.EventSegment` Event segments are subsets of events that were triggered on your site or app. |

### getName

The name for this segment. If unspecified, segments are named "Segment".

This name defines string value returned by the `segment` dimension. The
`segment` dimension prefixes segment names by the 1-based index number of
the segment in the request (for example "1. Segment", "2. Segment", etc.).

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

### setName

The name for this segment. If unspecified, segments are named "Segment".

This name defines string value returned by the `segment` dimension. The
`segment` dimension prefixes segment names by the 1-based index number of
the segment in the request (for example "1. Segment", "2. Segment", etc.).

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

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

### getUserSegment

User segments are subsets of users who engaged with your site or app.

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

### hasUserSegment

### setUserSegment

User segments are subsets of users who engaged with your site or app.

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

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

### getSessionSegment

Session segments are subsets of the sessions that occurred on your site
or app.

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

### hasSessionSegment

### setSessionSegment

Session segments are subsets of the sessions that occurred on your site
or app.

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

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

### getEventSegment

Event segments are subsets of events that were triggered on your site or
app.

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

### hasEventSegment

### setEventSegment

Event segments are subsets of events that were triggered on your site or
app.

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

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

### getOneSegmentScope

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