> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Node.js Product Analytics installation Canonical URL: https://posthog.com/docs/product-analytics/installation/nodejs > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host). ## On this page - [Install with the wizard](#install-with-the-wizard) - [Install the package](#install-the-package) - [Initialize PostHog](#initialize-posthog) - [Send an event](#send-an-event) - [Next steps](#next-steps) ## Install with the wizard Run this command in your project directory to add PostHog to your Node.js project. The wizard detects your framework, installs the SDK, and sets up your first events. `npx @posthog/wizard` Or set it up manually by following the rest of this guide. 1. 1 ## Install the package Required Install the PostHog Node.js library using your package manager: ### npm ```bash npm install posthog-node@5 ``` ### yarn ```bash yarn add posthog-node@5 ``` ### pnpm ```bash pnpm add posthog-node@5 ``` ### bun ```bash bun add posthog-node@5 ``` 2. 2 ## Initialize PostHog Required Initialize the PostHog client with your project token: Node.js ```javascript import { PostHog } from 'posthog-node' const client = new PostHog( '', { host: 'https://us.i.posthog.com' } ) ``` 3. 3 ## Send an event Recommended Once installed, you can manually send events to test your integration: Node.js ```javascript client.capture({ distinctId: 'distinct_id_of_the_user', event: 'event_name', properties: { property1: 'value', property2: 'value', }, }) // The client sends events in batches. Call shutdown() before the process // exits so that queued events are sent. In a long-running server, call it // once when the server stops. await client.shutdown() ``` 4. 4 ## Next steps Recommended Now that you're capturing events, continue with the resources below to learn what else Product Analytics enables within the PostHog platform. | Resource | Description | | --- | --- | | [Capturing events](https://posthog.com/docs/product-analytics/capture-events.md) | Learn how to capture custom events beyond autocapture | | [Identifying users](https://posthog.com/docs/product-analytics/identify.md) | Associate events with specific users | | [Creating insights](https://posthog.com/docs/product-analytics/insights.md) | Build trends, funnels, and retention charts | | [Group analytics](https://posthog.com/docs/product-analytics/group-analytics.md) | Track events at the company or account level |