Skip to main content
This page covers advanced usage of the Remark SDK, providing developers with more sophisticated control over the chat widget and user experience.

Initialization

Safely wait for the SDK before calling window.remark.

Widget Control

Programmatically open, close, hide, and show the chat widget.

Event Handling

Listen to user interactions and create custom integrations.

Waiting for Remark to initialize

Because the Remark script loads asynchronously, window.remark may not be available when your code runs. Before calling window.remark, wait for the remark:session-initialized event on window:
If your code might run before or after initialization, you can check whether window.remark is already available:

Customizing your user experience with the Remark SDK

The Remark SDK can also be used to control the state of the chat widget. You may wish, for example, to temporarily close the chat widget when displaying full-screen promotions or open the chat widget when a customer clicks on a certain call-to-action on your site. You can open, close, hide, and show the chat widget using one of the options in the following code.
Remark saves the hidden state in the browser, so the widget stays hidden on later page loads until you call show. To close the chat panel for a moment, use close instead.

Opening the widget with options

In addition to simply opening the widget, you can pass options to prefill a message or send it right away.

Available options

  • message – Text for the chat input. On its own, it fills the input and leaves sending to the shopper.
  • mode – Set to 'send' to send message right away, starting a conversation (or reopening a closed one) if needed. The default, 'pre-fill', only fills the input.
Embedded and floating widget coordination: When both the floating chat (<remark-chat-widget>) and embedded chat (<remark-qa-activator>) appear on the same page, they coordinate automatically. Only one widget holds the active conversation at a time — the other shows a “paused” state with the matched expert’s avatar and a button to resume the conversation there.On mobile viewports (480 px and below), tapping a prompt in the embedded chat opens the floating widget full-screen instead of starting an inline conversation. The floating widget does not auto-reopen from persisted state across page navigations on mobile — it stays closed unless explicitly opened via remark_open=true or window.remark('open').

Setting the widget language

The widget uses English unless your workspace has more languages enabled. To add languages, contact support@remark.ai. With more than one language enabled, the widget follows the storefront’s language: Shopify’s active locale, then the page’s <html lang> attribute, then the browser language. To set the language yourself, pass a language code or tag:
Remark saves your choice in the browser and uses it on later page loads until you set the language again.

URL Parameters

Remark recognizes several URL parameters for controlling widget behavior without writing code. These are useful for testing and sharing links that demonstrate a specific widget configuration. Append them as query parameters to any page URL:
The preview parameters only override the dashboard setting. For a visitor in the A/B control group, or on a page your rules exclude, add remark_force_widget=true as well. remark_force_widget, remark_preview_inline_elements, and remark_preview_floating_widget are also written to sessionStorage when set via URL, so the override persists across page navigations within the same tab. You can also set them directly in sessionStorage, which helps in browsers or environments that strip query parameters:
To clear an override, close the tab or remove the key from sessionStorage in DevTools. remark_reset_chat applies once, on the page load that carries it, and Remark doesn’t save it.

Listening for Remark Events

Remark fires remark:-prefixed DOM events from the floating widget, the embedded chat, and the page itself. Listen on window to receive all of them:

Listen to all Remark Events

To listen to all the events, you can use the window.remark.events.listenAll function. It takes a callback, called with every remark event. The payload received by the callback is an object: listenAll returns an object with an unsubscribe function. Calling that unsubscribe function will stop the callback from being called again.

List of Remark Events