Skip to main content

User Identification

Identify users to track their activity and deliver personalized messages:
import ZixflowDataPipelines

// Identify user with ID only
Zixflow.shared.identify(userId: "user@example.com")

// Identify user with additional attributes
Zixflow.shared.identify(
    userId: "user@example.com",
    traits: [
        "first_name": "John",
        "last_name": "Doe",
        "email": "user@example.com",
        "plan": "premium"
    ]
)
Read the current IDs (read-only):
let anonymousId = Zixflow.shared.anonymousId
let userId = Zixflow.shared.userId

Event Tracking

Track custom events:
// Simple event
Zixflow.shared.track(name: "Button Clicked")

// Event with properties
Zixflow.shared.track(
    name: "Product Purchased",
    properties: [
        "product_id": "123",
        "product_name": "Widget",
        "price": 29.99,
        "currency": "USD"
    ]
)

Screen Tracking

Track screen views manually:
Zixflow.shared.screen(
    title: "Product Detail",
    properties: [
        "product_id": "123",
        "category": "Electronics"
    ]
)

// Optional category overload
Zixflow.shared.screen(title: "Checkout", category: "Commerce")
Enable automatic UIKit screen tracking in configuration:
let config = SDKConfigBuilder(apiKey: "YOUR_API_KEY")
    .autoTrackUIKitScreenViews()
    .build()
For SwiftUI, call screen from .onAppear (see Platform-Specific Guides).

Profile Attributes

Update traits on the currently identified profile:
Zixflow.shared.setProfileAttributes([
    "age": 30,
    "subscription_status": "active"
])

Device Attributes

Set custom device attributes (auto device attributes are enabled by default):
Zixflow.shared.setDeviceAttributes([
    "store_region": "us-west",
    "preferred_language": "en"
])

Alias

Associate the current user with a new ID:
Zixflow.shared.alias(newId: "new-user-id")

User Logout and Reset

// Clear the identified user (also deletes the device token from the profile)
Zixflow.shared.clearIdentify()

// Full analytics reset (traits, userId, anonymousId)
Zixflow.shared.reset()

Flush Events

Force the SDK to send queued events immediately:
Zixflow.shared.flush {
    print("Flush completed")
}

Get Device Token

Retrieve the registered push notification device token:
if let deviceToken = Zixflow.shared.registeredDeviceToken {
    print("Device token: \(deviceToken)")
} else {
    print("Device token not yet registered")
}