# Views, labels, and user context

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fsdk-installation%2Froku%2Ffeatures%2Fviews-and-user-context.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fsdk-installation%2Froku%2Ffeatures%2Fviews-and-user-context.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

Views, labels, and user context are the three things you attach to records rather than send on their own. Each applies to every record that follows it, so setting them once shapes everything the SDK reports afterwards.

### View tracking[​](#view-tracking "Direct link to View tracking")

Name each screen with [`startView`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#startview) when it is shown, and clear it with [`endView`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#endview). Records carry the current view name:

```
m.global.cxRum.callfunc("startView", "Home")

m.global.cxRum.callfunc("startView", "Player")   ' replaces Home

m.global.cxRum.callfunc("endView")               ' clears the current view
```

### Labels[​](#labels "Direct link to Labels")

[`setLabels`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#setlabels) adds labels, or changes existing ones, on every record that follows. [`getLabels`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#getlabels) returns the channel-wide set as it currently stands:

```
' initialized with labels: { tier: "free" }

m.global.cxRum.callfunc("setLabels", { tier: "premium", ab_test: "b" })



labels = m.global.cxRum.callfunc("getLabels")   ' { tier: "premium", ab_test: "b" }
```

Labels passed to a single log or error apply to that record only. Keys are lowercased as described under [Custom logs](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/logs-and-errors.md#custom-logs).

Note

Two separate 512-character limits apply, each measured on the serialized labels: one on the channel-wide set (`coralogix_roku_initialize()` plus every `setLabels`), and one on the labels passed to a single call. The SDK ignores a `setLabels` call that takes the channel-wide set over its limit, and drops an oversized per-call set from that record. Both drop the labels whole rather than truncating them, and both warn on the console.

### User context[​](#user-context "Direct link to User context")

Set the viewer with [`setUserContext`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#setusercontext) after a sign-in, or clear it after a sign-out. Records from then on carry the new user:

```
m.global.cxRum.callfunc("setUserContext", {

    user_id: "user-1",

    user_name: "Jane",

    user_email: "jane@example.com",

    user_metadata: { plan: "family" }

})



m.global.cxRum.callfunc("setUserContext", {})   ' signed out
```

[`setUserContext`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#setusercontext) replaces the whole user: a field you don't pass is cleared. Fields: `user_id`, `user_name`, `user_email`, `account_id`, `account_name` (strings) and `user_metadata` (an object). The SDK refuses a call with an unknown field and warns on the console.

Note

The user context is limited to 512 characters once serialized, and `user_metadata` is where that limit is usually reached. Over it, the SDK refuses the whole context, including the fields that fit, keeps the previous user, and warns on the console. The same limit applies to the `user_context` you pass to `coralogix_roku_initialize()`.
