Update Messenger on route changes in a single-page app

Reevaluate website workflows, attribution, and launcher visibility after client-side navigation.

A client-side route transition can change the page without reloading the widget. Install the snippet once in the application shell. Call update from the router’s navigation-complete callback, after the browser address reflects the new route.

// After the new route is active
SupportDesk('update');

// When you have fresh tokens for the same signed-in customer
SupportDesk('update', {
  messenger_token: newMessengerToken,
  event_token: newEventToken
});

Ordinary navigation only needs the first call. If the account changes, call SupportDesk('shutdown') before booting the new user with tokens issued for that account.

Test by navigating from one route to another without reloading. If a website workflow has a path condition, use a matching route and a nonmatching route. Verify the prompt appears under the configured conditions, including any required time on the page.

Related reading

Was this article helpful?