> For the complete documentation index, see [llms.txt](https://docs.chartbeat.com/cbp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chartbeat.com/cbp/tracking/mobile-app-sdks/ios-sdk/video-tracking.md).

# Video Tracking

When a video loads in a view, call `trackVideo` to send Chartbeat the video information (see definitions below):

{% code overflow="wrap" %}

```swift
CBTracker.shared().trackVideo(
    "/video/123",       // viewId
    "My Video",         // title
    "https://...jpg",   // thumbnail (may be null)
    0L,                 // engagedTime (seconds)
    300_000L,           // duration (milliseconds)
    "s2",               // playState — see below
    0L,                 // contentTime (seconds)
    0L                  // playerTime (milliseconds)
);
```

{% endcode %}

Call `updateVideoPlayState` every few seconds while a video is playing to send the current video state.

{% code overflow="wrap" %}

```swift
CBTracker.shared().updateVideoPlayState(
    "s2",               // playState — see below
    300_000L,           // duration (milliseconds)
    0L,                 // engagedTime (seconds)
    0L,                 // contentTime (seconds)
    0L                  // playerTime (milliseconds)
);
```

{% endcode %}

|             |                                                                                                                     |
| ----------- | ------------------------------------------------------------------------------------------------------------------- |
| viewId      | A string unique identifier for this video, starting with a slash ('/'), similar to a relative path on a website (p) |
| title       | A string title for the content of the video (i)                                                                     |
| engagedTime | The amount of video played, including ads, in seconds (E)                                                           |
| duration    | The length of the video in milliseconds (\_vd)                                                                      |
| playState   | The play state: "s1" = unplayed, "s2" = played, "s3" = paused/stopped, "s4" = finished (\_vs)                       |
| contentTime | The amount of content played, excluding ads, in seconds (\_vce)                                                     |
| playerTime  | The time reported on the video player, in milliseconds (\_vpt)                                                      |

**Play states**

| Value | Meaning          |
| ----- | ---------------- |
| s1    | Unplayed         |
| s2    | Played           |
| s3    | Paused / stopped |
| s4    | Finished         |
