Setting up page view events

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.

Below is a code sample showing how to send a page view event.

The API accepts a PageView object as a parameter. 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` objectval pageView = PageView(url = url, pageTitle = pageTitle)Zendesk.instance.sendPageView(pageView,    successCallback = { user -> },    failureCallback = { error -> })

Java

Below is a code sample showing how to send a page view event.

The API accepts a PageView object as a parameter. Pass the location of the screen that the end user is on to url and the name of the screen to pageTitle.

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) {    }});