Skip to main content

User Identification

Identify users to track their activity:
// Identify user with ID only
Zixflow.instance.identify(userId: 'user@example.com');

// Identify user with additional attributes
Zixflow.instance.identify(
  userId: 'user@example.com',
  traits: {
    'first_name': 'John',
    'last_name': 'Doe',
    'email': 'user@example.com',
    'plan': 'premium',
    'created_at': DateTime.now().toIso8601String(),
  },
);

Event Tracking

Track custom events:
// Simple event
Zixflow.instance.track(name: 'button_clicked');

// Event with properties
Zixflow.instance.track(
  name: 'purchase_completed',
  properties: {
    'product_id': '123',
    'product_name': 'Widget',
    'price': 29.99,
    'currency': 'USD',
  },
);

// Event with timestamp
Zixflow.instance.track(
  name: 'order_completed',
  properties: {'order_id': 'ABC123'},
  timestamp: DateTime.now().millisecondsSinceEpoch,
);

Screen Tracking

Track screen views:
// Manual screen tracking
Zixflow.instance.screen(
  title: 'Product Detail',
  properties: {
    'product_id': '123',
    'category': 'Electronics',
  },
);

Automatic Screen Tracking with GoRouter

Enable automatic screen tracking by setting screenViewUse in configuration:
final config = ZixflowConfig(
  apiKey: 'YOUR_API_KEY',
  screenViewUse: ScreenView.all,  // Track all screens automatically
);

Profile Attributes

Set user profile attributes:
// Set profile attributes
Zixflow.instance.setProfileAttributes(
  attributes: {
    'age': 30,
    'gender': 'male',
    'subscription_status': 'active',
    'preferences': {'notifications': true},
  },
);

Device Attributes

Set device-specific attributes:
// Set device attributes
Zixflow.instance.setDeviceAttributes(
  attributes: {
    'app_theme': 'dark',
    'notifications_enabled': true,
    'preferred_language': 'en',
  },
);

User Logout

Clear user identification when they log out:
// Clear identified user
Zixflow.instance.clearIdentify();

Register Device Token

Register device token for push notifications:
Zixflow.instance.registerDeviceToken(deviceToken: 'YOUR_DEVICE_TOKEN');