Setting up page view events
Introduction
The PageView
object encapsulates information related to a user’s interactions and passes it to the Page View Event API. These session-based page view events can be seen in Agent Workspace by support agents using Zendesk.
Sending page view events
The API accepts a PageView
object, which should include:
url
: the unique location or path of the screen the user is currently viewing (for example, a route, deep link, or web URL).pageTitle
: a descriptive name for the screen, such as "Home", "Product Details", or "Checkout".
Providing accurate url
and pageTitle
values ensures that page view events are correctly tracked and can be used to trigger proactive messaging campaigns.
Pass the location of the screen that the end user is on to url
and the name of the screen to pageTitle
.
Kotlin
// Create a `PageView` object
val pageView = PageView(url = url, pageTitle = pageTitle)
Zendesk.instance.sendPageView(pageView,
successCallback = { user -> },
failureCallback = { error -> }
)
Java
PageView pageView = new PageView(url, pageTitle);
Zendesk.getInstance().sendPageViewEvent(pageView, new SuccessCallback<Unit>() {
@Override
public void onSuccess(Unit value) {
}
}, new FailureCallback<Throwable>() {
@Override
public void onFailure(@NonNull Throwable error) {
}
});
How page view events trigger proactive messaging
Proactive messaging campaigns in the Zendesk SDK rely on page view events to determine when and where to deliver targeted messages to users. Each time you send a page view event, the SDK evaluates whether the user matches the criteria for any active proactive campaigns. If a match is found, a proactive message is delivered.
Example flow: Page view event to Proactive message
- User navigates to a screen in your app.
- App sends a page view event** using the SDK (see code samples above).
- SDK evaluates active proactive campaigns** based on the event data.
- If criteria match, a proactive message is delivered** to the user.
Best practices for integrating page view events
- Send a page view event every time a user enters a screen that should be tracked for proactive messaging.
- Ensure the
url
andpageTitle
accurately reflect the user's location and context. - Send events promptly—delays may prevent timely delivery of proactive messages.
- Test your integration to confirm that proactive messages are triggered as expected.