Skip to content

Introduction

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

View as Markdown llms.txt
  • Node.js >= 20
  • A Segmentify account with an API key
Terminal window
npm install @segmentify/integration
# or
pnpm add @segmentify/integration
# or
yarn add @segmentify/integration
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: ['/'],
},
},
});
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',
});

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>

The package ships with multiple formats:

FileFormatUse Case
dist/index.es.jsES ModuleModern bundlers (Vite, webpack, Rollup)
dist/index.jsCommonJSNode.js / legacy bundlers
dist/index.d.tsTypeScript DeclarationsType checking and IDE support