# Introduction

> This guide will help you set up the Segmentify integration library in your project.

## Prerequisites

- Node.js >= 20
- A Segmentify account with an API key

## Quick Start

### 1. Install the package

```bash
npm install @segmentify/integration
# or
pnpm add @segmentify/integration
# or
yarn add @segmentify/integration
```

### 2. Initialize the library

```typescript
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

```typescript
import { SegmentifyEventManager } from '@segmentify/integration';

// Track a page view
SegmentifyEventManager().PageView({
  name: 'PAGE_VIEW',
});

// Track a product view
SegmentifyEventManager().ProductView({
  productId: 'PROD-123',
  title: 'Amazing Product',
  price: 99.99,
  category: 'electronics',
});
```

## As a Script Tag

For non-bundled environments, include the UMD build directly:

```html
<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

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?

- [Configuration](/02-configuration) — Full configuration reference
- [Events](/05-events) — Complete guide to event tracking
