# 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                                        |
|                     |                                                          |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.chartbeat.com/cbp/tracking/mobile-app-sdks/android-sdk/api-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
