Skip to Content

TrackEvents

POST
/analytics/v1/events

Authorization

headerX-API-Key<token>

API key for protected endpoints, supplied in the X-API-Key header.

Request Body

required
application/json
{
  "$ref": "#/components/schemas/analytics.v1.TrackEventsRequest",
  "$ref-value": {
    "type": "object",
    "properties": {
      "user_id": {
        "type": "string",
        "examples": [
          "QwErTy1234"
        ],
        "title": "user_id"
      },
      "country": {
        "type": "string",
        "examples": [
          "US"
        ],
        "title": "country"
      },
      "events": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/analytics.v1.AnalyticsEvent",
          "$ref-value": {
            "type": "object",
            "not": {
              "allOf": [
                {
                  "anyOf": [
                    {
                      "required": [
                        "session_start"
                      ]
                    },
                    {
                      "required": [
                        "content_view"
                      ]
                    },
                    {
                      "required": [
                        "engagement"
                      ]
                    },
                    {
                      "required": [
                        "interaction"
                      ]
                    },
                    {
                      "required": [
                        "error"
                      ]
                    }
                  ]
                },
                {
                  "not": {
                    "oneOf": [
                      {
                        "required": [
                          "session_start"
                        ]
                      },
                      {
                        "required": [
                          "content_view"
                        ]
                      },
                      {
                        "required": [
                          "engagement"
                        ]
                      },
                      {
                        "required": [
                          "interaction"
                        ]
                      },
                      {
                        "required": [
                          "error"
                        ]
                      }
                    ]
                  }
                }
              ]
            },
            "properties": {
              "timestamp": {
                "examples": [
                  "2026-01-15T10:30:00Z"
                ],
                "title": "timestamp",
                "$ref": "#/components/schemas/google.protobuf.Timestamp",
                "$ref-value": {
                  "type": "string",
                  "examples": [
                    "2023-01-15T01:30:15.01Z",
                    "2024-12-25T12:00:00Z"
                  ],
                  "format": "date-time",
                  "description": "A point in time in RFC 3339 format, with up to nanosecond precision. Output uses UTC (`Z`); input may use an offset from UTC."
                }
              },
              "session_start": {
                "title": "session_start",
                "$ref": "#/components/schemas/analytics.v1.SessionStartEvent",
                "$ref-value": {
                  "type": "object",
                  "properties": {
                    "utm_source": {
                      "type": "string",
                      "examples": [
                        "newsletter"
                      ],
                      "title": "utm_source"
                    },
                    "utm_campaign": {
                      "type": "string",
                      "examples": [
                        "summer_launch"
                      ],
                      "title": "utm_campaign"
                    },
                    "browser": {
                      "type": "string",
                      "examples": [
                        "Chrome"
                      ],
                      "title": "browser"
                    },
                    "language": {
                      "type": "string",
                      "examples": [
                        "en-US"
                      ],
                      "title": "language"
                    },
                    "screen_resolution": {
                      "type": "string",
                      "examples": [
                        "1920x1080"
                      ],
                      "title": "screen_resolution"
                    },
                    "platform": {
                      "type": "string",
                      "examples": [
                        "web"
                      ],
                      "title": "platform"
                    },
                    "tg_platform": {
                      "type": "string",
                      "examples": [
                        "tdesktop"
                      ],
                      "title": "tg_platform"
                    },
                    "tg_version": {
                      "type": "string",
                      "examples": [
                        "7.2.0"
                      ],
                      "title": "tg_version"
                    },
                    "timezone": {
                      "type": "string",
                      "examples": [
                        "America/New_York"
                      ],
                      "title": "timezone"
                    },
                    "timezone_offset": {
                      "type": "number",
                      "examples": [
                        "0.85"
                      ],
                      "title": "timezone_offset",
                      "format": "double"
                    },
                    "color_depth": {
                      "type": "number",
                      "examples": [
                        "0.85"
                      ],
                      "title": "color_depth",
                      "format": "double"
                    },
                    "touch_support": {
                      "type": "boolean",
                      "examples": [
                        "true"
                      ],
                      "title": "touch_support"
                    },
                    "country": {
                      "type": "string",
                      "examples": [
                        "US"
                      ],
                      "title": "country"
                    },
                    "user_id": {
                      "type": "string",
                      "examples": [
                        "QwErTy1234"
                      ],
                      "title": "user_id"
                    }
                  },
                  "title": "SessionStartEvent",
                  "additionalProperties": false
                }
              },
              "content_view": {
                "title": "content_view",
                "$ref": "#/components/schemas/analytics.v1.ContentViewEvent",
                "$ref-value": {
                  "type": "object",
                  "properties": {
                    "content_id": {
                      "type": "string",
                      "examples": [
                        "FpzVPNx1cG"
                      ],
                      "title": "content_id"
                    },
                    "content_type": {
                      "examples": [
                        "MEDIA_TYPE_VIDEO"
                      ],
                      "title": "content_type",
                      "$ref": "#/components/schemas/analyticscommon.v1.MediaType",
                      "$ref-value": {
                        "type": "string",
                        "title": "MediaType",
                        "enum": [
                          "MEDIA_TYPE_UNSPECIFIED",
                          "MEDIA_TYPE_IMAGE",
                          "MEDIA_TYPE_VIDEO"
                        ]
                      }
                    },
                    "feed_id": {
                      "type": "string",
                      "examples": [
                        "F4edRI23XL"
                      ],
                      "title": "feed_id"
                    },
                    "post_id": {
                      "type": "string",
                      "examples": [
                        "Mn0bVc9xZ8"
                      ],
                      "title": "post_id"
                    },
                    "view_type": {
                      "type": "string",
                      "examples": [
                        "post_view"
                      ],
                      "title": "view_type",
                      "enum": [
                        "start",
                        "watch",
                        "end"
                      ]
                    },
                    "watch_duration_ms": {
                      "title": "watch_duration_ms",
                      "$ref": "#/components/schemas/google.protobuf.Duration",
                      "$ref-value": {
                        "type": "string",
                        "pattern": "^-?[0-9]+(\\.[0-9]{1,9})?s$",
                        "description": "A signed duration in seconds, with up to nine fractional digits and an `s` suffix (for example, `3s` or `-0.001s`)."
                      }
                    },
                    "page": {
                      "type": "string",
                      "examples": [
                        "/feed"
                      ],
                      "title": "page",
                      "enum": [
                        "profile",
                        "feed",
                        "standalone"
                      ]
                    },
                    "video_position_ms": {
                      "title": "video_position_ms",
                      "$ref": "#/components/schemas/google.protobuf.Duration",
                      "$ref-value": {
                        "type": "string",
                        "pattern": "^-?[0-9]+(\\.[0-9]{1,9})?s$",
                        "description": "A signed duration in seconds, with up to nine fractional digits and an `s` suffix (for example, `3s` or `-0.001s`)."
                      }
                    },
                    "video_total_duration_ms": {
                      "title": "video_total_duration_ms",
                      "$ref": "#/components/schemas/google.protobuf.Duration",
                      "$ref-value": {
                        "type": "string",
                        "pattern": "^-?[0-9]+(\\.[0-9]{1,9})?s$",
                        "description": "A signed duration in seconds, with up to nine fractional digits and an `s` suffix (for example, `3s` or `-0.001s`)."
                      }
                    },
                    "segments": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/analytics.v1.Segment",
                        "$ref-value": {
                          "type": "object",
                          "properties": {
                            "start_ms": {
                              "title": "start_ms",
                              "$ref": "#/components/schemas/google.protobuf.Duration",
                              "$ref-value": {
                                "type": "string",
                                "pattern": "^-?[0-9]+(\\.[0-9]{1,9})?s$",
                                "description": "A signed duration in seconds, with up to nine fractional digits and an `s` suffix (for example, `3s` or `-0.001s`)."
                              }
                            },
                            "end_ms": {
                              "title": "end_ms",
                              "$ref": "#/components/schemas/google.protobuf.Duration",
                              "$ref-value": {
                                "type": "string",
                                "pattern": "^-?[0-9]+(\\.[0-9]{1,9})?s$",
                                "description": "A signed duration in seconds, with up to nine fractional digits and an `s` suffix (for example, `3s` or `-0.001s`)."
                              }
                            },
                            "speed": {
                              "type": "number",
                              "examples": [
                                "0.85"
                              ],
                              "title": "speed",
                              "format": "double"
                            },
                            "subtitle_language": {
                              "type": "string",
                              "examples": [
                                "en"
                              ],
                              "title": "subtitle_language",
                              "description": "Unset fields inherit the value the view was opened with."
                            },
                            "audio_language": {
                              "type": "string",
                              "examples": [
                                "fr"
                              ],
                              "title": "audio_language"
                            },
                            "quality": {
                              "title": "quality",
                              "$ref": "#/components/schemas/analyticscommon.v1.VideoQuality",
                              "$ref-value": {
                                "type": "string",
                                "title": "VideoQuality",
                                "enum": [
                                  "VIDEO_QUALITY_UNSPECIFIED",
                                  "VIDEO_QUALITY_BASIC",
                                  "VIDEO_QUALITY_SHORTS",
                                  "VIDEO_QUALITY_PRO"
                                ]
                              }
                            },
                            "chapter_title": {
                              "type": "string",
                              "examples": [
                                "Introduction"
                              ],
                              "title": "chapter_title"
                            }
                          },
                          "title": "Segment",
                          "additionalProperties": false
                        }
                      },
                      "title": "segments"
                    },
                    "device_id": {
                      "type": "string",
                      "examples": [
                        "QwErTy1234"
                      ],
                      "title": "device_id"
                    },
                    "country": {
                      "type": "string",
                      "examples": [
                        "US"
                      ],
                      "title": "country"
                    },
                    "subtitle_language": {
                      "type": "string",
                      "examples": [
                        "en"
                      ],
                      "title": "subtitle_language"
                    },
                    "audio_language": {
                      "type": "string",
                      "examples": [
                        "en"
                      ],
                      "title": "audio_language"
                    },
                    "quality": {
                      "title": "quality",
                      "$ref": "#/components/schemas/analyticscommon.v1.VideoQuality",
                      "$ref-value": {
                        "type": "string",
                        "title": "VideoQuality",
                        "enum": [
                          "VIDEO_QUALITY_UNSPECIFIED",
                          "VIDEO_QUALITY_BASIC",
                          "VIDEO_QUALITY_SHORTS",
                          "VIDEO_QUALITY_PRO"
                        ]
                      }
                    }
                  },
                  "title": "ContentViewEvent",
                  "additionalProperties": false
                }
              },
              "engagement": {
                "title": "engagement",
                "$ref": "#/components/schemas/analytics.v1.EngagementEvent",
                "$ref-value": {
                  "type": "object",
                  "properties": {
                    "engagement_type": {
                      "type": "string",
                      "examples": [
                        "like"
                      ],
                      "title": "engagement_type"
                    },
                    "resource_type": {
                      "type": "string",
                      "examples": [
                        "post"
                      ],
                      "title": "resource_type"
                    },
                    "resource_id": {
                      "type": "string",
                      "examples": [
                        "Mn0bVc9xZ8"
                      ],
                      "title": "resource_id"
                    },
                    "page": {
                      "type": "string",
                      "examples": [
                        "/feed"
                      ],
                      "title": "page"
                    },
                    "comment_text": {
                      "type": "string",
                      "examples": [
                        "Great post!"
                      ],
                      "title": "comment_text"
                    },
                    "share_platform": {
                      "type": "string",
                      "examples": [
                        "telegram"
                      ],
                      "title": "share_platform"
                    },
                    "country": {
                      "type": "string",
                      "examples": [
                        "US"
                      ],
                      "title": "country"
                    },
                    "device_type": {
                      "type": "string",
                      "examples": [
                        "mobile"
                      ],
                      "title": "device_type"
                    }
                  },
                  "title": "EngagementEvent",
                  "additionalProperties": false
                }
              },
              "interaction": {
                "title": "interaction",
                "$ref": "#/components/schemas/analytics.v1.InteractionEvent",
                "$ref-value": {
                  "type": "object",
                  "properties": {
                    "interaction_type": {
                      "type": "string",
                      "examples": [
                        "click"
                      ],
                      "title": "interaction_type"
                    },
                    "element_type": {
                      "type": "string",
                      "examples": [
                        "button"
                      ],
                      "title": "element_type"
                    },
                    "element_id": {
                      "type": "string",
                      "examples": [
                        "play_button"
                      ],
                      "title": "element_id"
                    },
                    "session_id": {
                      "type": "string",
                      "examples": [
                        "Bq4y3QB38S"
                      ],
                      "title": "session_id"
                    },
                    "page": {
                      "type": "string",
                      "examples": [
                        "/feed"
                      ],
                      "title": "page"
                    },
                    "page_url": {
                      "type": "string",
                      "examples": [
                        "https://example.com"
                      ],
                      "title": "page_url"
                    },
                    "scroll_depth": {
                      "type": "number",
                      "examples": [
                        "0.85"
                      ],
                      "title": "scroll_depth",
                      "format": "double"
                    },
                    "search_query": {
                      "type": "string",
                      "examples": [
                        "funny videos"
                      ],
                      "title": "search_query"
                    },
                    "click_x": {
                      "type": "integer",
                      "examples": [
                        "1250"
                      ],
                      "title": "click_x",
                      "format": "int32"
                    },
                    "click_y": {
                      "type": "integer",
                      "examples": [
                        "1250"
                      ],
                      "title": "click_y",
                      "format": "int32"
                    },
                    "device_type": {
                      "type": "string",
                      "examples": [
                        "mobile"
                      ],
                      "title": "device_type"
                    },
                    "browser": {
                      "type": "string",
                      "examples": [
                        "Chrome"
                      ],
                      "title": "browser"
                    }
                  },
                  "title": "InteractionEvent",
                  "additionalProperties": false
                }
              },
              "error": {
                "title": "error",
                "$ref": "#/components/schemas/analytics.v1.ErrorEvent",
                "$ref-value": {
                  "type": "object",
                  "properties": {
                    "error_type": {
                      "type": "string",
                      "examples": [
                        "network_error"
                      ],
                      "title": "error_type"
                    },
                    "error_code": {
                      "type": "string",
                      "examples": [
                        "ERR_TIMEOUT"
                      ],
                      "title": "error_code"
                    },
                    "error_message": {
                      "type": "string",
                      "examples": [
                        "Request timed out"
                      ],
                      "title": "error_message"
                    },
                    "stack_trace": {
                      "type": "string",
                      "examples": [
                        "at fetchData (app.js:42)"
                      ],
                      "title": "stack_trace"
                    },
                    "resource_type": {
                      "type": "string",
                      "examples": [
                        "post"
                      ],
                      "title": "resource_type"
                    },
                    "resource_id": {
                      "type": "string",
                      "examples": [
                        "Mn0bVc9xZ8"
                      ],
                      "title": "resource_id"
                    },
                    "endpoint": {
                      "type": "string",
                      "examples": [
                        "/analytics/v1/events"
                      ],
                      "title": "endpoint"
                    },
                    "session_id": {
                      "type": "string",
                      "examples": [
                        "Bq4y3QB38S"
                      ],
                      "title": "session_id"
                    },
                    "device_type": {
                      "type": "string",
                      "examples": [
                        "mobile"
                      ],
                      "title": "device_type"
                    },
                    "browser": {
                      "type": "string",
                      "examples": [
                        "Chrome"
                      ],
                      "title": "browser"
                    },
                    "os": {
                      "type": "string",
                      "examples": [
                        "iOS"
                      ],
                      "title": "os"
                    }
                  },
                  "title": "ErrorEvent",
                  "additionalProperties": false
                }
              }
            },
            "title": "AnalyticsEvent",
            "additionalProperties": false,
            "description": "At most one of `session_start`, `content_view`, `engagement`, `interaction`, `error` may be set."
          }
        },
        "title": "events"
      },
      "city": {
        "type": "string",
        "examples": [
          "New York"
        ],
        "title": "city"
      },
      "region": {
        "type": "string",
        "examples": [
          "NY"
        ],
        "title": "region"
      },
      "device": {
        "type": "string",
        "examples": [
          "mobile"
        ],
        "title": "device"
      },
      "os": {
        "type": "string",
        "examples": [
          "iOS"
        ],
        "title": "os"
      },
      "os_version": {
        "type": "string",
        "examples": [
          "16.4.1"
        ],
        "title": "os_version"
      },
      "language": {
        "type": "string",
        "examples": [
          "en-US"
        ],
        "title": "language"
      },
      "browser": {
        "type": "string",
        "examples": [
          "Safari"
        ],
        "title": "browser"
      },
      "project_id": {
        "type": "string",
        "examples": [
          "Pr0j3ctId01"
        ],
        "title": "project_id",
        "description": "Project the events belong to (Organization > Project > Videos/Images/Posts/Feeds).\n Sent alongside the other envelope-level context because a client session is scoped\n to one project. org_id is still derived server-side from the credential and is\n never taken from the body, so a wrong project_id can only mis-attribute within the\n caller's own organization."
      }
    },
    "title": "TrackEventsRequest",
    "additionalProperties": false
  }
}

Response Body

200application/json

Success

type: unknown

{
  "$ref": "#/components/schemas/google.protobuf.Empty",
  "$ref-value": {
    "type": "object",
    "description": "An empty JSON object."
  }
}
default
curl -X POST 'https://api.rixl.com/analytics/v1/events'

Success

application/json

{
  "$ref": "#/components/schemas/google.protobuf.Empty",
  "$ref-value": {
    "type": "object",
    "description": "An empty JSON object."
  }
}