> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peec.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get AI Referrals

> AI-referral traffic from the project's connected Google Analytics property, scoped to the hosts the project owns and to referrals from AI assistants. There is no way to ask this endpoint for non-AI traffic.

To list the values a dimension takes, pass it as the only `group_by` and read the rows — that is how you discover event names, countries, pages and the assistants that actually sent traffic. When populating a filter, do not filter by the dimension you are listing, or the options the user has not already picked disappear.

Metric definitions, because the names are shorter than the meanings:
- `events`: GA4 event count.
- `session_starts`: GA4 `session_start` events, which is not GA4's `sessions` metric. Most are visits that entered on the site; the rest resumed there after idling past GA4's session timeout. It cannot be combined with `group_by=event_name`.
- `conversions`: GA4 key events, so one visit can contribute several, and which events count follows whatever the property marked as a key event.
- `revenue`: GA4 purchase revenue in the property's reporting currency, returned as `currency`.

Unknown dimension values come back as `(not set)`. It is a real row, and the free-string filters (`sources`, `devices`, `event_names`, `mediums`) accept it back; `countries` does not, because it takes ISO codes only. Figures are a lower bound on AI referrals: only referrer-visible traffic reaches GA4, so native apps and no-referrer policies land as Direct, and Gemini is often folded into Organic Search.



## OpenAPI

````yaml https://api.peec.ai/customer/v1/openapi/json get /agent-analytics/google-analytics/referrals
openapi: 3.0.3
info:
  title: Peec AI Customer API
  description: Development documentation
  version: 1.0.0
  contact:
    name: Peec AI Team
    email: support@peec.ai
servers:
  - url: https://api.peec.ai/customer/v1
security: []
paths:
  /agent-analytics/google-analytics/referrals:
    get:
      tags:
        - Agent Analytics
      summary: Get AI Referrals
      description: >-
        AI-referral traffic from the project's connected Google Analytics
        property, scoped to the hosts the project owns and to referrals from AI
        assistants. There is no way to ask this endpoint for non-AI traffic.


        To list the values a dimension takes, pass it as the only `group_by` and
        read the rows — that is how you discover event names, countries, pages
        and the assistants that actually sent traffic. When populating a filter,
        do not filter by the dimension you are listing, or the options the user
        has not already picked disappear.


        Metric definitions, because the names are shorter than the meanings:

        - `events`: GA4 event count.

        - `session_starts`: GA4 `session_start` events, which is not GA4's
        `sessions` metric. Most are visits that entered on the site; the rest
        resumed there after idling past GA4's session timeout. It cannot be
        combined with `group_by=event_name`.

        - `conversions`: GA4 key events, so one visit can contribute several,
        and which events count follows whatever the property marked as a key
        event.

        - `revenue`: GA4 purchase revenue in the property's reporting currency,
        returned as `currency`.


        Unknown dimension values come back as `(not set)`. It is a real row, and
        the free-string filters (`sources`, `devices`, `event_names`, `mediums`)
        accept it back; `countries` does not, because it takes ISO codes only.
        Figures are a lower bound on AI referrals: only referrer-visible traffic
        reaches GA4, so native apps and no-referrer policies land as Direct, and
        Gemini is often folded into Organic Search.
      operationId: getAgent-analyticsGoogle-analyticsReferrals
      parameters:
        - name: project_id
          in: query
          required: false
          schema:
            description: Required if using a company api key
            example: or_f45b94ba-5e35-4982-93ed-285e72ee14eb
            type: string
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date
            pattern: >-
              ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$
            description: >-
              Inclusive bound, as full-date notation per RFC 3339 section 5.6.
              Required. A range spans at most 366 days.
            example: '2026-09-22'
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date
            pattern: >-
              ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))$
            description: >-
              Inclusive bound, as full-date notation per RFC 3339 section 5.6.
              Required. A range spans at most 366 days.
            example: '2026-09-22'
        - name: group_by
          in: query
          required: false
          schema:
            description: >-
              Dimension(s) to break the numbers down by, at most 3. Omit for
              period totals only. Pass a single dimension to list the values it
              takes.
            example:
              - assistant
            type: array
            items:
              type: string
              enum:
                - assistant
                - platform
                - source
                - medium
                - country
                - device
                - event_name
                - landing_page
                - page_path
                - host
        - name: metrics
          in: query
          required: false
          schema:
            description: >-
              Metrics to return. Defaults to all of them, minus session_starts
              when grouping by event_name. Unrequested metrics are left out of
              the query.
            example:
              - session_starts
              - conversions
            type: array
            items:
              type: string
              enum:
                - events
                - session_starts
                - conversions
                - revenue
        - name: time_bucket
          in: query
          required: false
          schema:
            description: >-
              Adds a time_bucket column holding the bucket's start date. There
              is no hourly bucket: the source data is daily. Buckets at either
              end of the range cover only the days inside it.
            example: week
            type: string
            enum:
              - day
              - week
              - month
        - name: assistants
          in: query
          required: false
          schema:
            description: >-
              Filter by assistant display name. An unrecognised name is rejected
              rather than ignored.
            example:
              - ChatGPT
            type: array
            items:
              type: string
        - name: sources
          in: query
          required: false
          schema:
            description: Filter by raw GA4 sessionSource host.
            example:
              - chatgpt.com
            type: array
            items:
              type: string
        - name: countries
          in: query
          required: false
          schema:
            description: Filter by ISO 3166-1 alpha-2 country code.
            example:
              - DE
            type: array
            items:
              type: string
              enum:
                - AE
                - AL
                - AM
                - AR
                - AT
                - AU
                - BA
                - BE
                - BG
                - BH
                - BO
                - BR
                - BS
                - BY
                - CA
                - CH
                - CL
                - CN
                - CO
                - CR
                - CY
                - CZ
                - DE
                - DK
                - DO
                - EC
                - EE
                - EG
                - ES
                - FI
                - FR
                - GB
                - GE
                - GH
                - GR
                - GT
                - HK
                - HN
                - HR
                - HU
                - ID
                - IE
                - IL
                - IN
                - IQ
                - IS
                - IT
                - JO
                - JP
                - KR
                - KW
                - LB
                - LI
                - LT
                - LU
                - LV
                - MA
                - MD
                - ME
                - MK
                - MN
                - MT
                - MX
                - MY
                - NG
                - NI
                - NL
                - 'NO'
                - NZ
                - OM
                - PK
                - PA
                - PE
                - PH
                - PL
                - PT
                - PY
                - PS
                - QA
                - RO
                - RS
                - SA
                - SE
                - SG
                - SI
                - SK
                - SV
                - TH
                - TN
                - TR
                - TW
                - UA
                - US
                - UY
                - VE
                - VN
                - ZA
                - AD
                - AF
                - AS
                - AZ
                - BB
                - BQ
                - CG
                - CI
                - CM
                - CW
                - DM
                - DZ
                - FO
                - GF
                - GP
                - JM
                - KG
                - KH
                - KI
                - KZ
                - LK
                - LR
                - LS
                - MW
                - NC
                - PG
                - TD
                - TF
                - UG
                - VU
                - ZW
        - name: mediums
          in: query
          required: false
          schema:
            description: >-
              Filter by GA4 session medium. Use `ai-assistant` to isolate
              traffic identified by medium rather than by a known referrer host.
            example:
              - ai-assistant
            type: array
            items:
              type: string
        - name: devices
          in: query
          required: false
          schema:
            description: >-
              Filter by device category. Property-specific and case-sensitive:
              an unmatched value yields zeros rather than an error.
            example:
              - mobile
            type: array
            items:
              type: string
        - name: event_names
          in: query
          required: false
          schema:
            description: >-
              Filter by GA4 event name. Property-specific: a name this property
              never sends yields zeros rather than an error, so discover them
              with `group_by=event_name` first.
            example:
              - purchase
            type: array
            items:
              type: string
        - name: order_by
          in: query
          required: false
          schema:
            description: >-
              Field to sort by, which must be one of the requested metrics (or
              time_bucket when it is set). Defaults to the first requested
              metric.
            example: session_starts
            type: string
            enum:
              - events
              - session_starts
              - conversions
              - revenue
              - time_bucket
        - name: order_direction
          in: query
          required: false
          schema:
            default: desc
            type: string
            enum:
              - asc
              - desc
        - name: include_total_count
          in: query
          required: false
          schema:
            description: >-
              Set false to skip total_count. Counting is a second pass over the
              same rows, so it doubles the cost of the call.
            example: 'false'
            default: 'true'
            type: string
            enum:
              - 'true'
              - 'false'
        - name: limit
          in: query
          required: false
          schema:
            default: 100
            type: integer
            minimum: 1
            maximum: 1000
        - name: offset
          in: query
          required: false
          schema:
            default: 0
            type: integer
            minimum: 0
            maximum: 9007199254740991
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        assistant:
                          example: ChatGPT
                          type: string
                        platform:
                          type: string
                          example: OpenAI
                        source:
                          example: chatgpt.com
                          type: string
                        medium:
                          example: referral
                          type: string
                        country:
                          example: DE
                          type: string
                        device:
                          example: mobile
                          type: string
                        event_name:
                          example: page_view
                          type: string
                        landing_page:
                          description: >-
                            The session's entry page, repeated on every event in
                            that session. Query string stripped.
                          example: /pricing
                          type: string
                        page_path:
                          description: >-
                            The page the event fired on. Query string stripped
                            and UUIDs collapsed to `*`, so it does not join to
                            landing_page.
                          example: /blog/*/overview
                          type: string
                        host:
                          example: www.example.com
                          type: string
                        time_bucket:
                          description: >-
                            First day of the bucket this row covers, always a
                            plain date. Present only when the `time_bucket`
                            request parameter was set, which names the width
                            rather than a date.
                          example: '2026-03-01'
                          type: string
                        events:
                          example: 4820
                          type: number
                        session_starts:
                          type: number
                          example: 1402
                        conversions:
                          example: 37
                          type: number
                        revenue:
                          example: 4210.5
                          type: number
                  columns:
                    type: array
                    items:
                      type: string
                    description: >-
                      Column order for the rows, derived from the request so a
                      zero-row answer still carries its shape.
                    example:
                      - assistant
                      - session_starts
                  total_count:
                    nullable: true
                    description: >-
                      Number of grouped rows the filters match — not a sum of
                      any metric. Null when include_total_count was false.
                    example: 12
                    type: number
                  currency:
                    nullable: true
                    description: >-
                      Reporting currency of `revenue`, null when revenue was not
                      requested. Values are not converted, so revenue is not
                      comparable across projects.
                    example: EUR
                    type: string
                required:
                  - data
                  - columns
                  - total_count
                  - currency
                description: Success
        '409':
          description: Response for status 409
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
      security:
        - APIKeyHeader: []
        - APIKeyQuery: []
        - BearerAuth: []
components:
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
    APIKeyQuery:
      type: apiKey
      in: query
      name: api_key
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````