Attribution
Retrieve install attribution metadata from OnsideKit, including the referring browser URL tied to a prior web session.
Requirements
Getting attribution metadata
@MainActor static func getAttributionMetadata(
completion: @escaping @MainActor (Result<OnsideAttributionMetadata, OnsideAttributionMetadataError>) -> Void
)struct OnsideAttributionMetadata {
var refererUrl: URL?
}Example
import UIKit
import OnsideKit
@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Call as early as possible for reliable attribution.
Onside.initialize()
Onside.getAttributionMetadata { result in
switch result {
case .success(let metadata):
if let refererUrl = metadata.refererUrl {
print("Onside refererUrl: \(refererUrl)")
// Send refererUrl to your analytics / backend if needed.
} else {
print("No refererUrl. Organic install or attribution unavailable.")
}
case .failure(let error):
print("Failed to fetch attribution metadata: \(error)")
}
}
return true
}
}Errors
Case
Cause
Suggested handling
Next
Last updated
Was this helpful?