Documentation
Getting started

Quickstart: Web (npm)

Add FounderHQ to a React, Next.js, Vue, or Svelte app with npm.

Install the package, initialize it once, and see your first event in FounderHQ. About 5 minutes.

Before you start

You need a FounderHQ account and a publishable key. In the app, open Analytics → Settings → Events SDK, create a key for Browser or mobile, and copy it. The full key is shown only once.

Nothing is sent anywhere. A publishable key is saved in this browser. A secret key is kept only until you reload.

Install the package

npm install @founderhq/events

Initialize once, at your app's entry point

import { founderhq } from "@founderhq/events";

founderhq.init("fhq_pk_XXXX");

founderhq is a shared client. Import it anywhere. Calling init a second time does nothing, so a hot reload is safe.

From here on, page views, page leaves, sessions, clicks, rage clicks, dead clicks, outbound clicks, scroll depth, and Core Web Vitals are captured for you. Single-page navigations count as page views.

Next.js App Router, or any framework that renders on the server? Put the call in a client component and render it once in your root layout.

"use client";

import { useEffect } from "react";
import { founderhq } from "@founderhq/events";

export function FounderHqAnalytics() {
  useEffect(() => {
    founderhq.init("fhq_pk_XXXX");
  }, []);
  return null;
}

FounderHQ records everything from the first page view. If your site asks visitors for consent first, start in the pending state and call consent when the visitor accepts:

founderhq.init("fhq_pk_XXXX", { consent_default: "pending" });

// Later, when the visitor accepts your banner:
founderhq.consent("granted");

While consent is pending, FounderHQ counts page views without cookies and records nothing else: identify and your own events are ignored. FounderHQ remembers the visitor's answer for 180 days. See Consent and privacy.

Identify the person when they sign in

founderhq.identify("user_8421", {
  email: "jane@acme.com",
  plan: "pro",
});

Pass your own stable user ID, not an email. FounderHQ merges the visitor's anonymous history into that contact.

Call founderhq.reset() when the person signs out, so the next visitor on that browser starts clean.

Capture your first event

founderhq.capture("trial.started", { plan: "pro" });

Use lowercase names you will still understand in six months. Event names that start with $ are reserved.

Verify

  1. Run your app and trigger the event.
  2. In FounderHQ, open Analytics → Events & Visits.
  3. You see trial.started with plan: pro, plus a $pageview.
  4. Open Analytics → People. Jane is there with her email.

Events can take a few seconds to appear. The SDK batches them. To send immediately, await founderhq.flush().

Troubleshoot

Nothing appears in Events

Check the network tab. If requests to /i/v2/e fail with a 401 or 403, the key is wrong or your origin is not allowed. Check Allowed browser origins on the key in Analytics → Settings → Events SDK.

You see page views but not your event

The visitor has not granted consent, so FounderHQ records page views only. This happens when your site starts with consent_default: "pending" or "denied". Check that founderhq.consent("granted") runs when they accept your banner.

Events fire twice in development

React Strict Mode runs effects twice. init is safe to call twice, but a capture inside an effect is not. Capture on the user's action, not on render.

Next

AI agent or LLM? Read this page as markdown

On this page