---
title: "Specifying widget context using Discover runtime JS"
slug: "specifying-widget-context-using-discover-runtime-js"
abstract: "Describes how you can provide contextual information using the Sitecore Discover runtime JS for improved results."
---
# Specifying widget context using Discover runtime JS

> [!note]
> Integration using Sitecore Discover runtime JS is deprecated.
>
> We recommend that you [use the Discover JS SDK](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/deprecated-integration-methods/integrate-with-discover-runtime-js/integrate-using-discover-sdks.html "Integrate using Discover SDKs") to integrate your website or [the Discover API](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/deprecated-integration-methods/integrate-with-discover-runtime-js/integrate-using-discover-rest-apis.html "Integrate using Discover REST APIs") for a website or application integration.

[Context information](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/deprecated-integration-methods/integrate-with-discover-runtime-js/specifying-widget-context-using-discover-runtime-js/the-updatecontext-object-model.html "The updateContext object model") enables Sitecore Discover to offer scalable custom widget behavior. In order for relevant products to be displayed to your users, you must ensure that context data is set correctly.

Widget context can be specified, changed, or cleared at runtime using `updateContext`.

There are a variety of reasons you might want to change the context at runtime. For example, if the user selects a locale, you can update the locale context to reflect that selection. Similarly, if the user selects their local store, you can update the store context. You might also want to update the context if the user selects a filter or category, or if the products displayed on the page change.

You might want to clear the context if the user logs out of their account, deselects filters or categories, and so on.

> [!important]
> Contextual information that is added at runtime does not persist from page to page. It must be added on every page where the change in context is required.

<details>
<summary><h2>Using updateContext</h2></summary>

To specify or [clear](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/deprecated-integration-methods/integrate-with-discover-runtime-js/specifying-widget-context-using-discover-runtime-js/clear-widget-context-using-runtime-js.html "Clear widget context using runtime JS") context, use the `rfk.push()` function with the `"updateContext"` action. The basic format for this function call is as follows:

```javascript
rfk.push(["updateContext", <updateContext object 1>, <updateContext object 2>, ...]);
```

In this code sample, `"updateContext"` is a constant string and the [updateContext object](https://doc.sitecore.com/discover/en/developers/discover-developer-guide/deprecated-integration-methods/integrate-with-discover-runtime-js/specifying-widget-context-using-discover-runtime-js/the-updatecontext-object-model.html "The updateContext object model") defines the widget(s) that the context applies to, the contexts to set, and the filter context to set.

</details>