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
- Swift Package Manager
- CocoaPods
In Xcode, open File → Add Package Dependencies. Add this URL.Add the
DatalyrSDK product to your app target.Initialize
Callconfigure 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 throughtrack().
screen() sends an event named pageview, not screen. Filter on pageview in
Events.[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
- SwiftUI
- UIKit
Identity
Callidentify() 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.
$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.
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
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
Complete method list
Every method below is onDatalyrSDK.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
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.respectDoNotTrackAutoEventConfig.trackAppUpdates. CalltrackAppUpdate()yourself.AutoEventConfig.trackPerformance
Call these instead
Limits
How failed requests behave
Storage
The SDK keeps its state inUserDefaults under these keys.
The SDK writes nothing to the Keychain.
Verify the install
- Run the app on a clean simulator or a fresh install.
- Open Events in Datalyr.
- Confirm
app_installandsession_startarrive within 30 seconds.
getStatus() and read initialized and queueStats. A queue
that grows without draining means the API key is wrong. See
No events.