pieowlDocs
JavaScript (Web)

JavaScript (Web)

Install the Pieowl Web SDK from npm to track page views, events and users in the browser, with TypeScript types.

Installation

Step 1: Install

bash
npm install @pieowl/web

Step 2: Initialize

pieowl.ts
import { Pieowl } from '@pieowl/web';

export const pieowl = new Pieowl({
  clientId: 'YOUR_CLIENT_ID',
});

clientId is enough. What the SDK collects by itself (page views, outside link clicks, data-track clicks, session replay) is set in Settings → Site → What Pieowl counts, not in code.

Options

Common options
  • apiUrl - The URL of the Pieowl API (default: https://api.pieowl.com). Change it only to send events through your own proxy
  • clientId - The client id of your application
  • clientSecret - The client secret of your application (only required for server-side events)
  • filter - A function that will be called before sending an event. If it returns false, the event will not be sent
  • disabled - If true, events are queued and not sent until you call ready() (useful for consent)
Web options

What the script collects by itself is set per site in Settings → Site → What Pieowl counts, not in code. The four options below are only a fallback, used when the script can't load those settings.

  • trackScreenViews - Fallback for Page views (default: true)
  • trackOutgoingLinks - Fallback for Clicks on links to other sites (default: true)
  • trackAttributes - Fallback for Clicks you marked in your code, elements with data-track (default: true)
  • trackHashChanges - Fallback for Address changes after #, for hash-based routers (default: false)
  • sessionReplay - Technical options for the screen recorder. Most sites need none. Turning replay on and choosing how many visits to record is done in Settings → Site → What Pieowl counts. Text and form fields are always hidden. See session replay docs.
    • blockSelector - CSS selector for elements to replace with a placeholder (default: [data-pieowl-replay-block])
    • blockClass - Class name that blocks elements from being recorded
    • ignoreSelector - CSS selector for elements excluded from interaction tracking
    • flushIntervalMs - How often (ms) recorded events are sent to the server (default: 10000)
    • maxEventsPerChunk - Maximum events per payload chunk (default: 200)
    • maxPayloadBytes - Maximum payload size in bytes (default: 1048576)
    • scriptUrl - Custom URL for the replay script (script-tag builds only)

Step 3: Usage

main.ts
import { pieowl } from './pieowl';

pieowl.track('my_event', { foo: 'bar' });

Usage

The Web SDK has the same methods as the JavaScript SDK. It also adds:

  • screenView() to track a page view by hand
  • Session replay, turned on per site in Settings → Site. See Session replay.
  • allowReplay() to start session replay once the visitor agrees, when Record only after visitors agree is on. See Consent management.

On this page

Need a hand?

Questions, issues or feature requests: email the Pieowl team.

hello@pieowl.com