Skip to main content

Initialize

import { Analytics } from '@zixflow/analytics-node'

const analytics = new Analytics({
  writeKey: 'YOUR_WRITE_KEY'
})

Identify a user

analytics.identify({
  userId: 'user@example.com',
  traits: {
    first_name: 'John',
    last_name: 'Doe',
    email: 'user@example.com'
  }
})

Track an event

analytics.track({
  userId: 'user@example.com',
  event: 'purchase_completed',
  properties: {
    product_id: '123',
    price: 29.99,
    currency: 'USD'
  }
})

Flush before exit

Always flush pending batches before the process exits:
await analytics.closeAndFlush()
Next: Core Features ยท API Reference