> 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/android-sdk/api-reference.md).

# API Reference

All methods are public static on com.chartbeat.androidsdk.Tracker.

#### Lifecycle

| Method                                                                             | Description                            |
| ---------------------------------------------------------------------------------- | -------------------------------------- |
| setupTracker(String accountId, String domain, Context appContext)                  | Initialize (defaults to ping endpoint) |
| setupTracker(String accountId, String domain, Context appContext, boolean usePong) | Initialize, optionally using pong      |
| stopTracker()                                                                      | Stop the tracker                       |
| pauseTracker()                                                                     | Pause while idle                       |
| backgroundTracker()                                                                | Pause when app is backgrounded         |
| restartPingService(Context)                                                        | Restart the ping scheduler             |

#### View tracking

| Method                                                                                                                                                | Description                                         |
| ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| trackView(Context, String viewId, String viewTitle)                                                                                                   | Track a view without scroll data                    |
| trackView(Context, String viewId, String viewTitle, int scrollPositionTop, int scrollWindowHeight, int totalContentHeight, int fullyRenderedDocWidth) | Track a view with scroll data                       |
| userLeftView(String viewId)                                                                                                                           | Report the user left a view (usually onPause)       |
| userInteracted()                                                                                                                                      | Report user interaction (usually onUserInteraction) |
| userTyped()                                                                                                                                           | Report typing/writing engagement                    |

#### Metadata

| Method                                                                  | Description                       |
| ----------------------------------------------------------------------- | --------------------------------- |
| setAuthors(String commaDelimited) / setAuthors(Collection\<String>)     | Article authors                   |
| setSections(String commaDelimited) / setSections(Collection\<String>)   | Article sections                  |
| setZones(String commaDelimited) / setZones(Collection\<String>)         | Content zones                     |
| setCustomData(HashMap\<String,String>)                                  | Arbitrary key/value metadata      |
| setDomain(String) / setSubdomain(String)                                | Override dashboard routing        |
| setAppReferrer(String) / setPushReferrer(String)                        | Referrers (call before trackView) |
| setViewLoadTime(float seconds)                                          | Record page-load time             |
| setPosition(int top, int windowHeight, int contentHeight, int docWidth) | Scroll position                   |

#### User state

| Method             | Description             |
| ------------------ | ----------------------- |
| setUserPaid()      | Mark as paid subscriber |
| setUserLoggedIn()  | Mark as logged in       |
| setUserAnonymous() | Mark as anonymous       |

#### Video

| Method                                                                                              | Description                  |
| --------------------------------------------------------------------------------------------------- | ---------------------------- |
| trackVideo(viewId, viewTitle, thumbnail, engagedTime, duration, playState, contentTime, playerTime) | Start tracking a video       |
| updateVideoPlayState(playState, duration, engagedTime, contentTime, playerTime)                     | Update in-flight video state |

#### Endpoint

| Method              | Description                                              |
| ------------------- | -------------------------------------------------------- |
| setUsePong(boolean) | Switch between ping.chartbeat.net and pong.chartbeat.net |
| getUsePong()        | true if using pong                                       |
| getEndpoint()       | Full endpoint URL                                        |
| getHost()           | Host portion only                                        |
|                     |                                                          |
