Subscribe to page events
-
Complete the SDK quick start.
When you query the page context, you retrieve details about the current page and site. You can also subscribe to page-related events. This way, your app receives real-time updates when the SitecoreAI user changes to a different version or language of the current page, or opens a different page.
To subscribe to page events:
-
Find the code where you queried the page context, typically
client.query("pages.context"), and replace it with the following code, then save your changes:This script adds a second parameter to your query to enable subscriptions. Every time a current page detail changes, the updates are logged to the console.
-
In the SitecoreAI Page builder, open your web browser's console, refresh the page, then open your Marketplace app.
-
In the console, filter your logs for
Page has been updated. -
In the site tree, click a different page. A new log appears in the console, containing the details of the page you opened.