Meta Ads (Facebook)
Overview
BillDog can record two Meta signals today:
- Facebook anonymous ID: stored on the BillDog customer and returned in the customer’s attribution data.
fbclid: recorded from the links your app opens, as properties on analytics events (iOS).
Coming soon: sending purchases and subscriptions to Meta (Conversions API), and joining Meta clicks to revenue. Today BillDog sends nothing to Meta. The ID and the click identifier are stored and recorded, and nothing reads them yet.
Facebook anonymous ID
Read the anonymous ID from the Facebook SDK and hand it to BillDog once after configure. The value is stored under the reserved attribution key fbAnonymousId and merged field by field, so a null never overwrites it.
// iOS — setter is async throws
import BillDogFull
import FBSDKCoreKit
Task {
try? await BillDog.shared.setFBAnonymousID(AppEvents.shared.anonymousID)
}// Android — suspend function returning Result<Unit>
import io.billdog.core.BillDog
import com.facebook.appevents.AppEventsLogger
scope.launch {
BillDog.getInstance().setFBAnonymousID(
AppEventsLogger.getAnonymousAppDeviceGUID(context)
)
}Click-through attribution (fbclid)
When a user arrives from a Meta ad, the URL your app opens carries an fbclid query parameter. On iOS, pass each URL your app opens to the analytics module’s trackDeepLink(_:). It records a $deep_link event and a $campaign_source event, both carrying the click ID and any UTM parameters. It works once the module is registered and BillDog is configured; session tracking is not needed.
import UIKit
import BillDogFull
final class AppDelegate: NSObject, UIApplicationDelegate {
let analytics = BillDogAnalyticsManager()
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
BillDog.shared.use(module: analytics)
BillDog.shared.configure(config: .init(apiKey: "YOUR_API_KEY"))
return true
}
// Custom URL scheme
func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
analytics.trackDeepLink(url)
return true
}
// Universal link
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let url = userActivity.webpageURL { analytics.trackDeepLink(url) }
return true
}
}Click identifiers recorded: fbclid (Meta), gclid (Google), ttclid (TikTok), twclid (X), li_fat_id (LinkedIn), msclkid (Microsoft). The first link that carries one is also saved on the device for 30 days (first touch). Nothing uses that saved value yet.
Deferred deep links (a link clicked before the app was installed) aren’t supported yet; that is coming soon. processDeferredDeepLink() only replays a link saved earlier on the same device, and the SDK gives your app no way to save one, so it currently does nothing.
Consent gating
setFBAnonymousID is gated by the SDK’s consent flag. If your app requires consent and it hasn’t been given, the call fails (iOS throws; Android returns a failed Result) and nothing is queued. Call it again after setConsentGiven(true). Deep-link events are analytics events, so they follow the analytics module’s opt-out instead: nothing is recorded for a user who has opted out of analytics. On iOS, the Facebook anonymous ID is not an IDFA and doesn’t itself require an ATT prompt, but your Meta SDK configuration may.
Related
Was this page helpful?
Or rate this page: