# Configuration

> Simple configuration example.

## Basic Configuration

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

new Initializer({
  domain: 'your-domain.com',
  apiKey: 'your-api-key',
  language: 'EN',
  currency: 'USD',
  spa: false,
  segmentifyApiUrl: '//your-api.segmentify.com',
});
```

## Configuration Reference

| Property            | Type                                                | Required | Description                                                            |
| ------------------- | --------------------------------------------------- | -------- | ---------------------------------------------------------------------- |
| `domain`            | `string`                                            | Yes      | Your website domain                                                    |
| `apiKey`            | `string`                                            | Yes      | Your Segmentify API key                                                |
| `language`          | `string`                                            | Yes      | Language code (e.g., `'EN'`, `'TR'`)                                   |
| `currency`          | `string`                                            | Yes      | Currency code (e.g., `'USD'`, `'EUR'`)                                 |
| `spa`               | `boolean`                                           | Yes      | Enable [SPA mode](/04-spa-mode) for client-side routing                |
| `segmentifyApiUrl`  | `string`                                            | Yes      | Segmentify API endpoint URL                                            |
| `segmentifyPushUrl` | `string`                                            | No       | Custom push endpoint URL                                               |
| `debug`             | `boolean \| 'DEBUG' \| 'INFO' \| 'WARN' \| 'ERROR'` | No       | Enable debug logging — see [Logger](/11-logger)                        |
| `searchify`         | `boolean`                                           | No       | Enable Searchify integration                                           |
| `ga`                | `object`                                            | No       | Google Analytics config (see below)                                    |
| `pageMap`           | `PageMap`                                           | No       | Page type mapping — see [Page Mapping](/03-page-mapping)               |
| `doNotPersonalize`  | `object`                                            | No       | Opt-out callback (see below)                                           |
| `allPageLogic`      | `object`                                            | No       | Global pre/post execute — see [Page Mapping](/03-page-mapping)         |
| `user`              | `User`                                              | No       | Pre-set user info — see [User Identification](/06-user-identification) |

## Google Analytics

```typescript
new Initializer({
  // ...required fields
  ga: {
    enabled: true,
    ga4: true, // true for GA4, false for Universal Analytics
  },
});
```

## Do Not Personalize

Provide a callback that returns `true` to opt out of personalization:

```typescript
new Initializer({
  // ...required fields
  doNotPersonalize: {
    cb: () => !hasConsent(), // e.g., check GDPR preferences
  },
});
```

## Initialization Behavior

- Calling `new Initializer()` twice logs a warning and skips the second call.
- The Segmentify SDK script is loaded asynchronously after DOM ready.
- Any events queued from the previous page are drained automatically.

## See Also

- [Page Mapping](/03-page-mapping)
- [SPA Mode](/04-spa-mode)
- [Logger](/11-logger)
