Skip to main content
Users
CloudPortalLogin
  • Powered byPowered by
Developing with Sitecore Personalize
Data privacy
Before you start sending data
Integrating with Sitecore Personalize
Stream API
Personalize API Flow execution
REST APIs
  • Sitecore Personalize for developers
  • Stream API
  • Sitecore Engage SDK reference
  • Functions
  • EngageServer.pageView(eventData, req[, extensionData])

EngageServer.pageView(eventData, req[, extensionData])

Note

This is a server-side function used for implementing server-side tracking. If you want to implement client-side tracking instead, use the client-side functions.

The pageView() function sends a VIEW event. The VIEW event triggers every time your webpage loads. You should send a VIEW event from every webpage that you want to track on your website.

sidebar. Parameters

Parameter

Type

Description

eventData

object

All the event data.

req

object

The HTTP request.

[extensionData]

optional

object

Custom data about an event.

Maximum 50 custom attributes of your choice.

Example 13. Next app

Here's an example of how to use the pageView() function in a Next app.

RequestResponse
export async function middleware(req) {
  const res = NextResponse.next();

  // Load Engage API
  const engageSettings = {
    clientKey: "<client_key_PLACEHOLDER>",
    targetURL: "<stream_api_target_endpoint_PLACEHOLDER>",
    pointOfSale: "<point_of_sale_PLACEHOLDER>"
  };

  const engageServer = await initServer(engageSettings);

  // Send VIEW events
  const eventData = {
    channel: "WEB",
    currency: "EUR"
  };

  const extensionData = {
    customKey: "customValue"
  };

  await engageServer.pageView(eventData, req, extensionData);
  return res;
};


Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2025 Sitecore