← Back

Track Pageviews With the Node.js SDK

Step 1: Install the NPM Package

Download and include the package via NPM:

npm install @knownagents/sdk

Step 2: Initialize the Client

In your code, create an instance of KnownAgents with your project's access token.

import { KnownAgents } from "@knownagents/sdk"

const knownAgents = new KnownAgents("YOUR_ACCESS_TOKEN")

Step 3: Track Pageviews

Call trackVisit with the incoming request and outgoing response. If you can, do this in middleware.

knownAgents.trackVisit(request, response)

Step 4: Test Your Integration

If your website is correctly connected, you should see visits from a test agent in the realtime timeline within a few seconds.