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

# Get CTR Analytics

> This route allows you to view the CTR analytics for a dataset.



## OpenAPI

````yaml post /api/analytics/events/ctr
openapi: 3.0.3
info:
  title: Trieve API
  description: >-
    Trieve OpenAPI Specification. This document describes all of the operations
    available through the Trieve API.
  contact:
    name: Trieve Team
    url: https://trieve.ai
    email: developers@trieve.ai
  license:
    name: BSL
    url: https://github.com/devflowinc/trieve/blob/main/LICENSE.txt
  version: 0.13.0
servers:
  - url: https://api.trieve.ai
    description: Production server
  - url: http://localhost:8090
    description: Local development server
security: []
tags:
  - name: Invitation
    description: Invitation endpoint. Exists to invite users to an organization.
  - name: Auth
    description: Authentication endpoint. Serves to register and authenticate users.
  - name: User
    description: User endpoint. Enables you to modify user roles and information.
  - name: Organization
    description: >-
      Organization endpoint. Enables you to modify organization roles and
      information.
  - name: Dataset
    description: >-
      Dataset endpoint. Datasets belong to organizations and hold configuration
      information for both client and server. Datasets contain chunks and chunk
      groups.
  - name: Chunk
    description: >-
      Chunk endpoint. Think of chunks as individual searchable units of
      information. The majority of your integration will likely be with the
      Chunk endpoint.
  - name: Chunk Group
    description: >-
      Chunk groups endpoint. Think of a chunk_group as a bookmark folder within
      the dataset.
  - name: Crawl
    description: Crawl endpoint. Used to create and manage crawls for datasets.
  - name: File
    description: >-
      File endpoint. When files are uploaded, they are stored in S3 and broken
      up into chunks with text extraction from Apache Tika. You can upload files
      of pretty much any type up to 1GB in size. See chunking algorithm details
      at `docs.trieve.ai` for more information on how chunking works. Improved
      default chunking is on our roadmap.
  - name: Events
    description: >-
      Notifications endpoint. Files are uploaded asynchronously and events are
      sent to the user when the upload is complete.
  - name: Topic
    description: >-
      Topic chat endpoint. Think of topics as the storage system for gen-ai chat
      memory. Gen AI messages belong to topics.
  - name: Message
    description: >-
      Message chat endpoint. Messages are units belonging to a topic in the
      context of a chat with a LLM. There are system, user, and assistant
      messages.
  - name: Stripe
    description: >-
      Stripe endpoint. Used for the managed SaaS version of this app. Eventually
      this will become a micro-service. Reach out to the team using contact info
      found at `docs.trieve.ai` for more information.
  - name: Health
    description: Health check endpoint. Used to check if the server is up and running.
  - name: Metrics
    description: Metrics endpoint. Used to get information for monitoring
  - name: Analytics
    description: Analytics endpoint. Used to get information for search and RAG analytics
  - name: Experiment
    description: Experiment endpoint. Used to create and manage experiments
paths:
  /api/analytics/events/ctr:
    post:
      tags:
        - Analytics
      summary: Get CTR Analytics
      description: This route allows you to view the CTR analytics for a dataset.
      operationId: get_ctr_analytics
      parameters:
        - name: TR-Dataset
          in: header
          description: >-
            The dataset id or tracking_id to use for the request. We assume you
            intend to use an id if the value is a valid uuid.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: JSON request payload to filter the graph
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CTRAnalytics'
        required: true
      responses:
        '200':
          description: The CTR analytics for the dataset
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CTRAnalyticsResponse'
        '400':
          description: Service error relating to getting CTR analytics
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      security:
        - ApiKey:
            - admin
components:
  schemas:
    CTRAnalytics:
      oneOf:
        - type: object
          title: SearchCTRMetrics
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/SearchAnalyticsFilter'
              nullable: true
            type:
              type: string
              enum:
                - search_ctr_metrics
        - type: object
          title: SearchesWithClicks
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/SearchAnalyticsFilter'
              nullable: true
            page:
              type: integer
              format: int32
              nullable: true
              minimum: 0
            type:
              type: string
              enum:
                - searches_with_clicks
        - type: object
          title: SearchesWithoutClicks
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/SearchAnalyticsFilter'
              nullable: true
            page:
              type: integer
              format: int32
              nullable: true
              minimum: 0
            type:
              type: string
              enum:
                - searches_without_clicks
        - type: object
          title: RecommendationCTRMetrics
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            type:
              type: string
              enum:
                - recommendation_ctr_metrics
        - type: object
          title: RecommendationsWithClicks
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            page:
              type: integer
              format: int32
              nullable: true
              minimum: 0
            type:
              type: string
              enum:
                - recommendations_with_clicks
        - type: object
          title: RecommendationsWithoutClicks
          required:
            - type
          properties:
            filter:
              allOf:
                - $ref: '#/components/schemas/RecommendationAnalyticsFilter'
              nullable: true
            page:
              type: integer
              format: int32
              nullable: true
              minimum: 0
            type:
              type: string
              enum:
                - recommendations_without_clicks
      discriminator:
        propertyName: type
    CTRAnalyticsResponse:
      oneOf:
        - $ref: '#/components/schemas/SearchCTRMetrics'
        - $ref: '#/components/schemas/CTRSearchQueryWithoutClicksResponse'
        - $ref: '#/components/schemas/CTRSearchQueryWithClicksResponse'
        - $ref: '#/components/schemas/RecommendationCTRMetrics'
        - $ref: '#/components/schemas/CTRRecommendationsWithoutClicksResponse'
        - $ref: '#/components/schemas/CTRRecommendationsWithClicksResponse'
    ErrorResponseBody:
      type: object
      required:
        - message
      properties:
        message:
          type: string
      example:
        message: Bad Request
    SearchAnalyticsFilter:
      type: object
      properties:
        component_name:
          type: string
          nullable: true
        date_range:
          allOf:
            - $ref: '#/components/schemas/DateRange'
          nullable: true
        query:
          type: string
          nullable: true
        query_rating:
          allOf:
            - $ref: '#/components/schemas/QueryRatingRange'
          nullable: true
        search_method:
          allOf:
            - $ref: '#/components/schemas/SearchMethod'
          nullable: true
        search_type:
          allOf:
            - $ref: '#/components/schemas/SearchType'
          nullable: true
        top_score:
          allOf:
            - $ref: '#/components/schemas/FloatRange'
          nullable: true
    RecommendationAnalyticsFilter:
      type: object
      properties:
        component_name:
          type: string
          nullable: true
        date_range:
          allOf:
            - $ref: '#/components/schemas/DateRange'
          nullable: true
        recommendation_type:
          allOf:
            - $ref: '#/components/schemas/RecommendationType'
          nullable: true
        top_score:
          allOf:
            - $ref: '#/components/schemas/FloatRange'
          nullable: true
    SearchCTRMetrics:
      type: object
      title: Search CTR Metrics
      required:
        - searches_with_clicks
        - percent_searches_with_clicks
        - percent_searches_without_clicks
        - avg_position_of_click
      properties:
        avg_position_of_click:
          type: number
          format: double
        percent_searches_with_clicks:
          type: number
          format: double
        percent_searches_without_clicks:
          type: number
          format: double
        searches_with_clicks:
          type: integer
          format: int64
    CTRSearchQueryWithoutClicksResponse:
      type: object
      title: SearchesWithoutClicks
      required:
        - queries
      properties:
        queries:
          type: array
          items:
            $ref: '#/components/schemas/SearchQueriesWithoutClicksCTRResponse'
    CTRSearchQueryWithClicksResponse:
      type: object
      title: SearchesWithClicks
      required:
        - queries
      properties:
        queries:
          type: array
          items:
            $ref: '#/components/schemas/SearchQueriesWithClicksCTRResponse'
    RecommendationCTRMetrics:
      type: object
      title: Recommendation CTR Metrics
      required:
        - recommendations_with_clicks
        - percent_recommendations_with_clicks
        - percent_recommendations_without_clicks
        - avg_position_of_click
      properties:
        avg_position_of_click:
          type: number
          format: double
        percent_recommendations_with_clicks:
          type: number
          format: double
        percent_recommendations_without_clicks:
          type: number
          format: double
        recommendations_with_clicks:
          type: integer
          format: int64
    CTRRecommendationsWithoutClicksResponse:
      type: object
      title: RecommendationsWithoutClicks
      required:
        - recommendations
      properties:
        recommendations:
          type: array
          items:
            $ref: '#/components/schemas/RecommendationsWithoutClicksCTRResponse'
    CTRRecommendationsWithClicksResponse:
      type: object
      title: RecommendationsWithClicks
      required:
        - recommendations
      properties:
        recommendations:
          type: array
          items:
            $ref: '#/components/schemas/RecommendationsWithClicksCTRResponse'
    DateRange:
      type: object
      description: >-
        DateRange is a JSON object which can be used to filter chunks by a range
        of dates. This leverages the time_stamp field on chunks in your dataset.
        You can specify this if you want values in a certain range. You must
        provide ISO 8601 combined date and time without timezone.
      properties:
        gt:
          type: string
          nullable: true
        gte:
          type: string
          nullable: true
        lt:
          type: string
          nullable: true
        lte:
          type: string
          nullable: true
      example:
        gt: '2021-01-01 00:00:00.000'
        gte: '2021-01-01 00:00:00.000'
        lt: '2021-01-01 00:00:00.000'
        lte: '2021-01-01 00:00:00.000'
    QueryRatingRange:
      type: object
      properties:
        gt:
          type: integer
          format: int32
          nullable: true
          minimum: 0
        gte:
          type: integer
          format: int32
          nullable: true
          minimum: 0
        lt:
          type: integer
          format: int32
          nullable: true
          minimum: 0
        lte:
          type: integer
          format: int32
          nullable: true
          minimum: 0
      example:
        gt: 1
        gte: 1
        lt: 1
        lte: 1
    SearchMethod:
      type: string
      enum:
        - fulltext
        - semantic
        - hybrid
        - bm25
    SearchType:
      type: string
      enum:
        - search
        - autocomplete
        - search_over_groups
        - search_within_groups
    FloatRange:
      type: object
      properties:
        gt:
          type: number
          format: double
          nullable: true
        gte:
          type: number
          format: double
          nullable: true
        lt:
          type: number
          format: double
          nullable: true
        lte:
          type: number
          format: double
          nullable: true
    RecommendationType:
      type: string
      enum:
        - Chunk
        - Group
    SearchQueriesWithoutClicksCTRResponse:
      type: object
      required:
        - query
        - request_id
        - created_at
      properties:
        created_at:
          type: string
        query:
          type: string
        request_id:
          type: string
    SearchQueriesWithClicksCTRResponse:
      type: object
      required:
        - query
        - results
        - clicked_chunk
        - request_id
        - created_at
      properties:
        clicked_chunk:
          $ref: '#/components/schemas/ChunkMetadataWithPosition'
        created_at:
          type: string
        query:
          type: string
        request_id:
          type: string
        results:
          type: array
          items: {}
    RecommendationsWithoutClicksCTRResponse:
      type: object
      required:
        - request_id
        - created_at
      properties:
        created_at:
          type: string
        negative_ids:
          type: array
          items:
            type: string
          nullable: true
        negative_tracking_ids:
          type: array
          items:
            type: string
          nullable: true
        positive_ids:
          type: array
          items:
            type: string
          nullable: true
        positive_tracking_ids:
          type: array
          items:
            type: string
          nullable: true
        request_id:
          type: string
    RecommendationsWithClicksCTRResponse:
      type: object
      required:
        - results
        - request_id
        - clicked_chunk
        - created_at
      properties:
        clicked_chunk:
          $ref: '#/components/schemas/ChunkMetadataWithPosition'
        created_at:
          type: string
        negative_ids:
          type: array
          items:
            type: string
          nullable: true
        negative_tracking_ids:
          type: array
          items:
            type: string
          nullable: true
        positive_ids:
          type: array
          items:
            type: string
          nullable: true
        positive_tracking_ids:
          type: array
          items:
            type: string
          nullable: true
        request_id:
          type: string
        results:
          type: array
          items: {}
    ChunkMetadataWithPosition:
      type: object
      required:
        - chunk
        - position
      properties:
        chunk:
          $ref: '#/components/schemas/ChunkMetadata'
        position:
          type: integer
          format: int32
    ChunkMetadata:
      type: object
      title: V2
      required:
        - id
        - created_at
        - updated_at
        - dataset_id
        - weight
      properties:
        chunk_html:
          type: string
          description: >-
            HTML content of the chunk, can also be an arbitrary string which is
            not HTML
          nullable: true
        created_at:
          type: string
          format: date-time
          description: Timestamp of the creation of the chunk
        dataset_id:
          type: string
          format: uuid
          description: ID of the dataset which the chunk belongs to
        id:
          type: string
          format: uuid
          description: >-
            Unique identifier of the chunk, auto-generated uuid created by
            Trieve
        image_urls:
          type: array
          items:
            type: string
            nullable: true
          description: >-
            Image URLs of the chunk, can be any list of strings. Used for image
            search and RAG.
          nullable: true
        link:
          type: string
          description: Link to the chunk, should be a URL
          nullable: true
        location:
          allOf:
            - $ref: '#/components/schemas/GeoInfo'
          nullable: true
        metadata:
          description: Metadata of the chunk, can be any JSON object
          nullable: true
        num_value:
          type: number
          format: double
          description: >-
            Numeric value of the chunk, can be any float. Can represent the most
            relevant numeric value of the chunk, such as a price, quantity in
            stock, rating, etc.
          nullable: true
        tag_set:
          type: array
          items:
            type: string
            nullable: true
          description: >-
            Tag set of the chunk, can be any list of strings. Used for
            tag-filtered searches.
          nullable: true
        time_stamp:
          type: string
          format: date-time
          description: Timestamp of the chunk, can be any timestamp. Specified by the user.
          nullable: true
        tracking_id:
          type: string
          description: >-
            Tracking ID of the chunk, can be any string, determined by the user.
            Tracking ID's are unique identifiers for chunks within a dataset.
            They are designed to match the unique identifier of the chunk in the
            user's system.
          nullable: true
        updated_at:
          type: string
          format: date-time
          description: Timestamp of the last update of the chunk
        weight:
          type: number
          format: double
          description: >-
            Weight of the chunk, can be any float. Used as a multiplier on a
            chunk's relevance score for ranking purposes.
      example:
        chunk_html: <p>Hello, world!</p>
        created_at: '2021-01-01 00:00:00.000'
        dataset_id: e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3e3
        id: e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3e3
        link: https://trieve.ai
        metadata:
          key: value
        tag_set: '[tag1,tag2]'
        time_stamp: '2021-01-01 00:00:00.000'
        tracking_id: e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3e3
        updated_at: '2021-01-01 00:00:00.000'
        weight: 0.5
    GeoInfo:
      type: object
      description: Location that you want to use as the center of the search.
      required:
        - lat
        - lon
      properties:
        lat:
          $ref: '#/components/schemas/GeoTypes'
        lon:
          $ref: '#/components/schemas/GeoTypes'
    GeoTypes:
      oneOf:
        - type: integer
          format: int64
        - type: number
          format: double
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

````