LogoLogo
  • Set up UserFlux
    • What is UserFlux?
  • Create an account
  • Start collecting data
  • View your data in UserFlux
  • Plan remaining implementation
  • Integration
    • Identify users
    • Send events
  • Enrich your data
  • Feature Guides
    • Insights
      • Series
      • Funnel
      • User Composition
      • Custom SQL
  • Reports
  • Segments & Computed Properties
  • Workflows
  • Destinations
  • Metrics API
  • Security
    • API Authentication
    • Trust Center
  • SDKs
    • Browser SDK
    • React SDK
    • Backend JS SDK
  • APIs
    • Profiles API
    • Events API
    • Metrics API
    • Workflow API
    • Products API
Powered by GitBook
On this page
  • Best Practices
  • 1. Start with Auto Capture on your frontend
  • 2. Instrument Custom Events
  • 3. Include properties on an event
  • 4. Follow Consistent Naming Conventions
  • 5. Sending events from the Client vs. Backend
  • 6. Understanding Ingestion Time
  1. Integration

Send events

Depending on your implementation you can use one of the code examples here for getting started with tracking custom events.

import UserFlux from '@userflux/browser-js'

await UserFlux.track({
    event: 'purchase',
    properties: { 
        "amount": 99.50,
        "currency": "AUD",
        "orderId": "order-id",
        "productId": "product-id",
        "fees": {
            "cardSurcharge": 0.99
        }
    },
    userId: '<USER_ID>' // replace <USER_ID> with your user's unique identifier
})
import { useUserFlux } from "@userflux/browser-js-react"

const userFlux = useUserFlux()

await userFlux.track({
    event: 'purchase',
    properties: { 
        "amount": 99.50,
        "currency": "AUD",
        "orderId": "order-id",
        "productId": "product-id",
        "fees": {
            "cardSurcharge": 0.99
        }
    },
    userId: '<USER_ID>' // replace <USER_ID> with your user's unique identifier
})
import UserFlux from '@userflux/backend-js'

const ufClient = new UserFlux('<YOUR_WRITE_KEY>', { ... })

await ufClient.track({
    userId: '<USER_ID>', // replace <USER_ID> with your user's unique identifier
    event: 'purchase',
    properties: { 
        "amount": 99.50,
        "currency": "AUD",
        "orderId": "order-id",
        "productId": "product-id",
        "fees": {
            "cardSurcharge": 0.99
        }
    }
})

Best Practices

1. Start with Auto Capture on your frontend

We recommend starting with Auto Capture in your web app. Auto Capture records clicks, page views and more—no manual instrumentation required. This gives you immediate coverage and a baseline for insights.

2. Instrument Custom Events

Once Auto Capture is in place, add custom events to track your product’s critical actions:

  • Signup flows

  • Feature uses

  • Purchases or upgrades

Use either the SDK or API to fire these events wherever they occur in your code.

3. Include properties on an event

We recommend providing as much context to an event as possible. Including more properties will help you filter, segment and analyse insights better later on.

There's no limit on the number properties an event can have and complex data types such as Arrays and Nested Objects are supported.

4. Follow Consistent Naming Conventions

Adopt clear, predictable event names. Event names do not support white spaces and should follow a common casing pattern such as TileCase, camelCase, or snake_case.

5. Sending events from the Client vs. Backend

We recommend sending high‑volume UI interactions client‑side. You should send critical, transactional events (e.g. payment succeeded) from your backend.

Backend‑side

  • Reliability: immune to ad‑blockers, network drop‑outs

  • Rich context: enrich with up‑to‑date database values

Client‑side

  • User context: captures browser/device details

  • Low overhead: instant capture of UI interactions

6. Understanding Ingestion Time

For transactional processes such as Workflows and Profile State Evaluations, data is ingested and available immediately.

For analytical processes such as queries and reporting, UserFlux is still generally very fast in terms of the time from event request sent to being available.

For analytical data availability, latency varies by throughput:

  • Low volume (<1k events/sec): available in ~30 seconds

  • High volume (≥1k events/sec): available in ~3  seconds

PreviousIdentify usersNextEnrich your data

Last updated 1 month ago

Events API