Skip to main content

User Identification

Identify users to track their activity:
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"
    ]
)

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"
    ]
)

// Event with timestamp
Zixflow.shared.track(
    name: "Order Completed",
    properties: ["order_id": "ABC123"],
    timestamp: Date()
)

Screen Tracking

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

// Enable automatic UIKit screen tracking (in configuration)
let config = SDKConfigBuilder(apiKey: "YOUR_API_KEY")
    .autoTrackUIKitScreenViews()
    .build()

Profile Attributes

Set user profile attributes:
// Set profile attributes
Zixflow.shared.setProfileAttributes([
    "age": 30,
    "gender": "male",
    "subscription_status": "active"
])

Device Attributes

Set device attributes:
// Set device-specific attributes
Zixflow.shared.deviceAttributes = [
    "app_version": "2.1.0",
    "device_model": "iPhone 14 Pro",
    "os_version": "iOS 16.4"
]

User Logout

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

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")
}