Introduction
This guide will help you set up the Segmentify integration library in your project.
Prerequisites
Section titled “Prerequisites”- Node.js >= 20
- A Segmentify account with an API key
Quick Start
Section titled “Quick Start”1. Install the package
Section titled “1. Install the package”npm install @segmentify/integration# orpnpm add @segmentify/integration# oryarn add @segmentify/integration2. Initialize the library
Section titled “2. Initialize the library”import { Initializer, type SegmentifyConfig } from '@segmentify/integration';
const AppConfig = { domain: 'segmentify.com', apiKey: '<API_KEY>', language: '', currency: '', segmentifyApiUrl: '', segmentifyPushUrl: '', doNotPersonalize: { cb: () => false, }, debug: 'DEBUG', spa: false, ga: { enabled: true, ga4: true, }, searchify: true,} as const satisfies SegmentifyConfig;
new Initializer({ ...AppConfig, pageMap: { 'Home Page': { type: 'Home Page', category: 'Home Page', pattern: ['/'], }, },});3. Start tracking events
Section titled “3. Start tracking events”import { SegmentifyEventManager } from '@segmentify/integration';
// Track a page viewSegmentifyEventManager().PageView({ name: 'PAGE_VIEW',});
// Track a product viewSegmentifyEventManager().ProductView({ productId: 'PROD-123', title: 'Amazing Product', price: 99.99, category: 'electronics',});As a Script Tag
Section titled “As a Script Tag”For non-bundled environments, include the UMD build directly:
<script src="dist/index.umd.js"></script><script> new SegmentifyIntegration.Initializer({ domain: 'your-domain.com', apiKey: 'your-api-key', language: 'EN', currency: 'USD', segmentifyApiUrl: '//your-api.segmentify.com', });</script>Build Outputs
Section titled “Build Outputs”The package ships with multiple formats:
| File | Format | Use Case |
|---|---|---|
dist/index.es.js | ES Module | Modern bundlers (Vite, webpack, Rollup) |
dist/index.js | CommonJS | Node.js / legacy bundlers |
dist/index.d.ts | TypeScript Declarations | Type checking and IDE support |
What’s Next?
Section titled “What’s Next?”- Configuration — Full configuration reference
- Events — Complete guide to event tracking