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

# Get AI Referrals

> Retrieve the visits AI assistants (ChatGPT, Perplexity, Gemini and others) sent to the brand's websites, with their engagement and conversions. Rows come from the brand's Google Analytics 4 connection and from the websites sent through the AI Referrals push API. This endpoint isn't part of the push beta: any key with `query` scope on the brand can call it.

## Freshness

Scrunch copies the brand's Google Analytics data once a day. Rows run up to yesterday in each website's time zone, so today isn't included. A day not loaded yet reads `null`. Grouped by `date` and `ai_platform` only, an assistant with no visits on a loaded day reads `0`. Numbers can differ slightly from Scrunch's AI Referrals page, which reads Google Analytics live.

A `start_date` before `2015-08-14`, when Google Analytics 4 starts, returns `400`. Revenue reported in different currencies across the brand's websites returns `409`.

## Available Dimensions

| Field | Description |
|-------|-------------|
| `date` | The day, `YYYY-MM-DD` |
| `ai_platform` | The AI assistant that referred the visits (e.g. `OpenAI`, `Perplexity`) |
| `landing_page` | Path of the page the visits landed on |
| `website` | The website the visits went to, without scheme or www |

## Metrics

Every row carries `sessions`, `views`, `engaged_sessions`, `engagement_rate`, `avg_engagement_time_per_session`, `new_users`, `key_events`, `converted_sessions`, `conversion_rate`, `transactions` and `revenue`. Key events leave out Google Analytics' automatic events and the ones the brand turned off in Scrunch. A website sent through the push API with traffic only reads `null` for `engaged_sessions`, `new_users`, `key_events`, `converted_sessions` and the rates.



## OpenAPI

````yaml /api-reference/openapi.json get /{brand_id}/ai-referrals
openapi: 3.1.0
info:
  title: Scrunch Data API
  version: 0.1.0
servers:
  - url: https://api.scrunchai.com/v1
security: []
paths:
  /{brand_id}/ai-referrals:
    get:
      tags:
        - ai-referrals
      summary: Get AI Referrals
      description: >-
        Retrieve the visits AI assistants (ChatGPT, Perplexity, Gemini and
        others) sent to the brand's websites, with their engagement and
        conversions. Rows come from the brand's Google Analytics 4 connection
        and from the websites sent through the AI Referrals push API. This
        endpoint isn't part of the push beta: any key with `query` scope on the
        brand can call it.


        ## Freshness


        Scrunch copies the brand's Google Analytics data once a day. Rows run up
        to yesterday in each website's time zone, so today isn't included. A day
        not loaded yet reads `null`. Grouped by `date` and `ai_platform` only,
        an assistant with no visits on a loaded day reads `0`. Numbers can
        differ slightly from Scrunch's AI Referrals page, which reads Google
        Analytics live.


        A `start_date` before `2015-08-14`, when Google Analytics 4 starts,
        returns `400`. Revenue reported in different currencies across the
        brand's websites returns `409`.


        ## Available Dimensions


        | Field | Description |

        |-------|-------------|

        | `date` | The day, `YYYY-MM-DD` |

        | `ai_platform` | The AI assistant that referred the visits (e.g.
        `OpenAI`, `Perplexity`) |

        | `landing_page` | Path of the page the visits landed on |

        | `website` | The website the visits went to, without scheme or www |


        ## Metrics


        Every row carries `sessions`, `views`, `engaged_sessions`,
        `engagement_rate`, `avg_engagement_time_per_session`, `new_users`,
        `key_events`, `converted_sessions`, `conversion_rate`, `transactions`
        and `revenue`. Key events leave out Google Analytics' automatic events
        and the ones the brand turned off in Scrunch. A website sent through the
        push API with traffic only reads `null` for `engaged_sessions`,
        `new_users`, `key_events`, `converted_sessions` and the rates.
      operationId: getAiReferrals
      parameters:
        - name: brand_id
          in: path
          required: true
          schema:
            type: integer
            title: Brand Id
          description: The unique identifier for the brand.
        - name: start_date
          in: query
          required: true
          schema:
            type: string
            format: date
            title: Start Date
            description: >-
              Start date for the query range (inclusive). Format: YYYY-MM-DD.
              Not before 2015-08-14.
          description: >-
            Start date for the query range (inclusive). Format: YYYY-MM-DD. Not
            before 2015-08-14.
        - name: end_date
          in: query
          required: true
          schema:
            type: string
            format: date
            description: 'End date for the query range (inclusive). Format: YYYY-MM-DD.'
            title: End Date
          description: 'End date for the query range (inclusive). Format: YYYY-MM-DD.'
        - name: fields
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Fields
            description: >-
              Comma-separated list of dimensions to group by. Available
              dimensions: `date`, `ai_platform`, `landing_page`, `website`.
              Defaults to `date,ai_platform`.
          description: >-
            Comma-separated list of dimensions to group by. Available
            dimensions: `date`, `ai_platform`, `landing_page`, `website`.
            Defaults to `date,ai_platform`.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 100000
            minimum: 1
            description: Maximum number of rows to return. Use with offset for pagination.
            default: 10000
            title: Limit
          description: Maximum number of rows to return. Use with offset for pagination.
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
            title: Offset
            description: Number of rows to skip before returning results.
          description: Number of rows to skip before returning results.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AiReferralsResponse'
        '400':
          description: >-
            A field in `fields` isn't a valid dimension, `start_date` is after
            `end_date`, or `start_date` is before 2015-08-14.
        '404':
          description: Brand not found.
        '409':
          description: The brand's websites report revenue in different currencies.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer:
            - query
components:
  schemas:
    AiReferralsResponse:
      properties:
        meta:
          $ref: '#/components/schemas/AiReferralsMeta'
          description: 'Query metadata: the date range and the revenue currency.'
        data:
          items:
            $ref: '#/components/schemas/AiReferralsRow'
          type: array
          title: Data
          description: AI referral rows grouped by the requested dimensions.
      type: object
      required:
        - meta
        - data
      title: AiReferralsResponse
      description: Response containing AI referral rows with metadata.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AiReferralsMeta:
      properties:
        start_date:
          type: string
          format: date
          title: Start Date
          description: Start date of the query range.
        end_date:
          type: string
          format: date
          title: End Date
          description: End date of the query range.
        currency_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Currency Code
          description: ISO 4217 code of `revenue`, when there is revenue.
      type: object
      required:
        - start_date
        - end_date
      title: AiReferralsMeta
      description: Metadata about the AI referrals query results.
    AiReferralsRow:
      properties:
        date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Date
          description: The day, YYYY-MM-DD. Only present when `date` is requested.
        ai_platform:
          anyOf:
            - type: string
            - type: 'null'
          title: Ai Platform
          description: >-
            The AI assistant that referred the visits (e.g. `OpenAI`,
            `Perplexity`). Only present when `ai_platform` is requested.
        landing_page:
          anyOf:
            - type: string
            - type: 'null'
          title: Landing Page
          description: >-
            Path of the page the visits landed on. Only present when
            `landing_page` is requested.
        website:
          anyOf:
            - type: string
            - type: 'null'
          title: Website
          description: >-
            The website the visits went to, without scheme or www. Only present
            when `website` is requested.
        sessions:
          anyOf:
            - type: integer
            - type: 'null'
          title: Sessions
          description: Sessions referred by AI assistants.
        views:
          anyOf:
            - type: integer
            - type: 'null'
          title: Views
          description: Page views in those sessions.
        engaged_sessions:
          anyOf:
            - type: integer
            - type: 'null'
          title: Engaged Sessions
          description: Engaged sessions.
        engagement_rate:
          anyOf:
            - type: number
            - type: 'null'
          title: Engagement Rate
          description: Engaged sessions / sessions, from 0 to 1.
        avg_engagement_time_per_session:
          anyOf:
            - type: number
            - type: 'null'
          title: Avg Engagement Time Per Session
          description: Engagement time per session, in seconds.
        new_users:
          anyOf:
            - type: integer
            - type: 'null'
          title: New Users
          description: First-time users.
        key_events:
          anyOf:
            - type: integer
            - type: 'null'
          title: Key Events
          description: >-
            Key events (conversions), without the events the brand turned off in
            Scrunch.
        converted_sessions:
          anyOf:
            - type: integer
            - type: 'null'
          title: Converted Sessions
          description: Sessions with at least one counted key event.
        conversion_rate:
          anyOf:
            - type: number
            - type: 'null'
          title: Conversion Rate
          description: Converted sessions / sessions, from 0 to 1.
        transactions:
          anyOf:
            - type: integer
            - type: 'null'
          title: Transactions
          description: Purchases.
        revenue:
          anyOf:
            - type: number
            - type: 'null'
          title: Revenue
          description: Purchase revenue, in `meta.currency_code`.
      type: object
      title: AiReferralsRow
      description: >-
        AI-referred visits for one combination of the requested dimensions. A
        dimension not requested is left out.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

## Related topics

- [AI Referrals API: Read and send AI referral traffic](https://developers.scrunch.com/api-reference/ai-referrals/overview.md)
- [List AI Referrals Connections](https://developers.scrunch.com/api-reference/ai-referrals/list-ai-referrals-connections.md)
- [Register AI Referrals Connection](https://developers.scrunch.com/api-reference/ai-referrals/register-ai-referrals-connection.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.