Skip to main content
Complete reference for DatalyrSDK 2.1.10, which posts events to https://ingest.datalyr.com/track. For a first install, start with Install in a mobile app.

Requirements

Install

In Xcode, open File → Add Package Dependencies. Add this URL.
Add the DatalyrSDK product to your app target.

Initialize

Call configure once, at app launch. Generate a write key under Settings → API.
initialize(config:) throws DatalyrError.invalidApiKey on an empty key. The SDK buffers up to 50 events, 50 identity calls, and 50 deep links sent before initialization.

What the SDK tracks without your code

The SDK never prompts for App Tracking Transparency on its own, and it never captures the launch URL. Call handleDeepLink(_:) yourself.

Events the SDK sends for you

These names are reserved. Never send one through track().
screen() sends an event named pageview, not screen. Filter on pageview in Events.
Event names accept [A-Za-z0-9_-.$] up to 100 characters. Whitespace runs collapse to _, so track("Order Completed") arrives as Order_Completed.

Track an event

Track a screen

Identity

Call identify() once per signed-in person, not on every screen. A call with a different userId runs reset() first, which rotates the anonymous ID and erases attribution, the journey, and the SKAdNetwork high-water value.
A repeat call with unchanged ID and traits sends no $identify event.

Identity on the wire

This SDK sends no distinct_id and no top-level visitor_id. To pass identity to RevenueCat or Superwall, use getRevenueCatAttributes() or getSuperwallAttributes().
reset() rotates the anonymous ID and session, and clears attribution, journey, and SKAdNetwork state.

Revenue

trackPurchase, trackSubscription, trackAddToCart, trackInitiateCheckout, trackCompleteRegistration, and trackLead update the SKAdNetwork conversion value. trackViewContent, trackSearch, and trackAddPaymentInfo do not.

Attribution

Pass every incoming link to the SDK.
The SDK reads these 38 parameters from the query string and the URL fragment. Key matching is case-insensitive. Each utm_* value is mirrored to campaign_source, campaign_medium, campaign_name, campaign_term, and campaign_content. Since 2.1.9 the whole attribution record rides on every event. Properties you pass to track() win on a name collision.

Apple Search Ads

The SDK reads AdServices on iOS 14.3 and later, and adds these 12 properties to every event: asa_attribution, asa_org_id, asa_org_name, asa_campaign_id, asa_campaign_name, asa_adgroup_id, asa_adgroup_name, asa_conversion_type, asa_click_date, asa_keyword, asa_keyword_id, asa_region. The fetch does not block initialize(), so the first events after install carry no asa_* values.

SKAdNetwork

initialize() registers for attribution. The framework depends on the OS version. Conversion values only ever increase. The SDK stores a high-water fine value and sends an update only for a strictly higher fine value, or an equal fine value with a higher coarse value.
Set skadTemplate at initialization to use conversion values. Without it, getConversionValue(for:) returns nil and trackWithSKAdNetwork() sends no postback update. Pass gaming or subscription for those templates. Any other string selects the ecommerce template.

Journey

The journey holds up to 30 touchpoints over a 90-day window. It is readable in the app only. The SDK attaches no journey field to any event.

App Tracking Transparency

Each call sends $att_status and refreshes idfa, att_status, and advertiser_tracking_enabled on later events. The SDK caches advertiser data once at initialization, so call this after the prompt resolves. ATT governs the advertising identifier. It is not an analytics consent system. Your app owns consent and the App Store privacy disclosure.

RevenueCat and Superwall

Call both after the two SDKs initialize, and again after the ATT prompt. See RevenueCat and Superwall.

Complete method list

Every method below is on DatalyrSDK.shared unless marked static. Each datalyr* free function mirrors its instance method. View.datalyrScreen(_:properties:), View.datalyrTrack(_:properties:), and UIViewController.datalyrTrackScreenView() wrap the same calls.

Configuration

timeout, retryDelay, and flushInterval are seconds on iOS. The React Native SDK uses milliseconds for the same three names. Copying timeout: 15000 from a React Native configuration produces a 15,000-second timeout.

AutoEventConfig

Note the unit split here: sessionTimeoutMs is milliseconds, and the other three interval options are seconds. sessionTimeoutMs sets when session_end fires. Session ID rotation is fixed at 30 minutes. trackScreenViews: false stops the internal screen counters. It does not stop the pageview event. screen() always sends one.

Options with no effect

Remove these three from your configuration.
  • DatalyrConfig.respectDoNotTrack
  • AutoEventConfig.trackAppUpdates. Call trackAppUpdate() yourself.
  • AutoEventConfig.trackPerformance

Call these instead

Limits

How failed requests behave

Storage

The SDK keeps its state in UserDefaults under these keys. The SDK writes nothing to the Keychain.

Verify the install

  1. Run the app on a clean simulator or a fresh install.
  2. Open Events in Datalyr.
  3. Confirm app_install and session_start arrive within 30 seconds.
If nothing arrives, call getStatus() and read initialized and queueStats. A queue that grows without draining means the API key is wrong. See No events.