facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.
https://developers.facebook.com/docs/ios
Other
7.8k stars 3.56k forks source link

App Events not reaching Facebook / SKAdNetwork attribution problems #1667

Closed danmaas closed 3 years ago

danmaas commented 3 years ago

(this is a follow-up to consolidate the main questions from #1632 and #1639)

To summarize, despite trying very hard to follow all the best practices around iOS 14 App Events and install attribution, we are still failing to get events to appear in Facebook's App Events Insights panel, and failing to attribute installs to iOS 14 campaigns in Ads Manager. We are not sure if this is a code bug, or incorrect interpretation of the documentation, or maybe an issue with Facebook's internal data systems rather than the iOS SDK.

Checklist

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

Goals/Expected Results

  1. The Facebook SDK remains dormant until we receive user consent to send data, after which:
  2. App Events appear in our Facebook App's Events insights panel, including both automatically-logged events like App Install plus manually-logged events from [FBSDKAppEvents logEvent].
  3. iOS 14 ad campaigns in Ads Manager show plausible App Install numbers, after waiting the proper 3 days for SKAdNetwork attribution to occur.

Note: at no point is the user signing in with a Facebook account, nor do we want to touch the IDFA at all. We only want to send what is possible without an active login session and without asking for IDFA.

(Actually, I'm afraid the docs are not very clear about whether this is even possible: can we send log events to Facebook without first asking the user to sign in, or querying the IDFA? It would be nice to clarify what data can be logged, if any, without these steps.)

Actual Results

All App Events do appear in the iOS device log, when enabled via [FBSDKSettings enableLoggingBehavior:FBSDKLoggingBehaviorAppEvents];. This includes both automatically-logged and manually-logged events.

However, we do NOT see any events in the Events Manager Test Events panel (https://business.facebook.com/events_manager2/list/app/APPID/test_events), nor the Facebook App Insights panel (https://www.facebook.com/analytics/APPID/AppEvents/), even after 1+ days of waiting.

We can get events to appear in the Test Events panel and App Insights, but only if we do two weird things that seem to contradict the documentation:

  1. We set the _implicitlyLogged flag to 1 on all events. This is an internal flag that the SDK normally adds only to automatically-logged events. Since automatically-logged events were occasionally appearing on the Test Events panel, we tried adding this flag ourselves, and suddenly all the events started appearing reliably (except App Install - see 2.).
  2. We send an App Install event manually by logging a custom event named fb_mobile_first_app_launch. Even though we do set [FBSDKSettings setAutoLogAppEventsEnabled:YES], the SDK doesn't seem to be sending its own App Install event.

With the above hacks, I think we are logging app events successfully.

However, we are doubtful that iOS 14 SKAdNetwork attribution is fully working yet, since we see far fewer App Install events in the Ads Manager interface than we would expect, relative to the number of link clicks and typical conversion rates of our campaigns. (based on historical trends, we are pretty confident that our click-to-install conversion rate should be at least 30%, but in Ads Manger we only see about 10% click-to-install on iOS 14 campaigns, which seems abnormally low).

Steps to Reproduce

Here is how we are interacting with the SDK:

Info.plist, AppDelegate.m:

After receiving user consent to share data (with explicit UI in GDPR countries, otherwise implicitly):

[FBSDKApplicationDelegate initializeSDK:nil];
[FBSDKSettings setAdvertiserTrackingEnabled:YES];
[FBSDKSettings setAutoLogAppEventsEnabled:YES];

i.e., we want to initialize the SDK and then send as much data as we possibly can, except without touching the IDFA.

After making the above 3 calls, I would expect to see events like App Install, App Launch, and our manually-logged events to start appearing in the Events Insights panel. (on Android, using the equivalent SDK calls, they indeed do appear). Also, I would expect that we should start seeing reasonable App Install counts on iOS 14 ad campaigns via SKAdNetwork, after waiting the proper 3-day period for delayed attribution.

SonChanthem commented 3 years ago

@varun-s, I've set up implement like below. But I still didn't get any events showing in test panel even standard event such app_install that is automatic record by SDK. I'm testing on real device iPhone X, iOS 14.6 and I had allow ATT prompt.

Implementation in AppDelegate method.

ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
Settings.isAutoLogAppEventsEnabled = true
Settings.isAdvertiserIDCollectionEnabled = true
ATTrackingManager.requestTrackingAuthorization { (status) in
   if status == .authorized {
      Settings.setAdvertiserTrackingEnabled(true)
   }
}

My info.plist file

<key>FacebookAdvertiserIDCollectionEnabled</key>
<true/>
<key>FacebookAppID</key>
<string>$(FB_APP_ID)</string>
<key>FacebookAutoLogAppEventsEnabled</key>
<true/>
<key>FacebookClientToken</key>
<string>$(FB_CLIENT_TOKEN)</string>
<key>FacebookDisplayName</key>
<string>$(FB_DISPLAY_NAME)</string>

Is your side have implement ATT prompt? As document mentioned it need to iOS 14.5. https://developers.facebook.com/docs/app-events/getting-started-app-events-ios/#get-device-consent

varun-s commented 3 years ago

@SonChanthem No, we are not using the ATT prompt. Are you logged-in to the Facebook app on the same device?

guerri-17 commented 3 years ago

@SonChanthem, @varun-s:

Thank you both - I finally have some test events working. I agree with Varun, this iOS SDK requires Facebook app to be running concurrently as your app on a physical device, in order for the Api requests to get to Facebook for logging.

I also have "ApplicationDelegate.initialize() return true" at the end of "func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {" in AppDelegate.swift.

I will test whether it is needed or not. I do not use ATT prompt and I created a Custom event (stackoverflow help):

let eventName: AppEvents.Name = AppEvents.Name(rawValue: "RequestMentor") AppEvents.logEvent(eventName) AppEvents.flush() //will test if this is needed or not

Attached is my Test Screen which shows up in both Facebook.com/events_manager2 and business.facebook.com/events_manager2:

Screen Shot 2021-07-19 at 8 16 19 PM
DomRiedweg commented 3 years ago

@varun-s Thank you for update about the client id, I also used the app name (according to the documentation at that time).

Anyway I'll fix that but before I waste another 3 days waiting for events, maybe someone can confirm if my settings should work (@KylinChang maybe, thank you).

Goal: No tracking except SKAN so I don't expect to see any events in event_manager2.

Version: 9.0.3

Initialise, it's not clear which method I need to call: ApplicationDelegate.initialize() Settings.initialize()

    Settings.setAdvertiserTrackingEnabled(false)
    Settings.isAutoLogAppEventsEnabled = true
    Settings.isAdvertiserIDCollectionEnabled = false

ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) is implemented in SceneDelegate.

Is my understanding correct that this should give me app_install through SKAN only?

Or can I also switch off AutoLogAppEvents and call SKAdNetwok manually, it’s only 2 different methods anyway SKAdNetwork.registerAppForAdNetworkAttribution() SKAdNetwork.updateConversionValue(1)

But I couldn’t find how optimise for my custom conversionValue in even_manager2 and my campaign settings (the higher the better).

I guess I should not mix calls to SKAdNetwork and enable AutoEvents, is that correct?

SonChanthem commented 3 years ago

@varun-s: Yes I do. My device had Facebook App and I also logged in Facebook account. One more thing as you mention, you didn't request ATT prompt. So What's the value do you set for this method Settings.setAdvertiserTrackingEnabled(false) or Settings.setAdvertiserTrackingEnabled(true)?. And did you testing from iOS 14?

How about these 2 methods?

ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
ApplicationDelegate.initialize()

Did you call both ? Which one is called first ? May you help the share the code in func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool ?

@guerri-17 : As your testing are working , Could you shared how do you set all these option both in plist file and in AppDelegate?

Settings.setAdvertiserTrackingEnabled(Boolean)
Settings.isAutoLogAppEventsEnabled = Boolean
Settings.isAdvertiserIDCollectionEnabled = Boolean

By the way, I'm not sure is it correct or not. but I requested ATT prompt base on this document mentioned that it need to set this flag True for iOS 14.5 up. https://web.facebook.com/business/help/2750680505215705?id=428636648170202&_rdc=1&_rdr

Screen Shot 2021-07-21 at 10 34 10 AM
julien-tamade commented 3 years ago

Also running into this issue of events not reaching the events manager. I'm using SDK version 11.0.1. I tried changing my setup to this:

ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) then I request Tracking permission

func requestTracking(){
        if #available(iOS 14, *) {
            AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 40)
            ATTrackingManager.requestTrackingAuthorization(completionHandler: { (status) in
                switch status{
                case .authorized:
                    Settings.setAdvertiserTrackingEnabled(true)
                    break
                case .denied:
                    Settings.setAdvertiserTrackingEnabled(false)
                default:
                    break
                }
                print("AppDelegate: permission decided \(status.rawValue)")
                self.initializeFBSDK()
            })
        }else{
            self.initializeFBSDK()
        }
    }

and finally initialize the sdk

func initializeFBSDK(){
        Settings.isAutoLogAppEventsEnabled = true
        Settings.isAdvertiserIDCollectionEnabled = true
        ApplicationDelegate.initialize()
    }

Still not receiving the events in events manager. Anybody have a definitive setup that works? The Facebook Documentation is really bad so I'm just swimming in the dark here? is ApplicationDelegate.initialize() required? is that supposed to be called before or after everything else? @DomRiedweg asked if Settings.initialize() needs to be called and I echo that? Anybody know what's gonna work?

tereshchenkoartyom94-da commented 3 years ago

@julien-tamade I made events work, but my comment has many dislikes

Do you have a Facebook app installed?

julien-tamade commented 3 years ago

@tereshchenkoartyom94-da yes I have the app and am logged in. Could you share how you're initializing the SDK? and is it working on iOS 14.6?

guerri-17 commented 3 years ago

@SonChanthem - I'm curious if you have actual aliases set up or they are just placeholders in lieu of your actual values for this forum thread - "$(FB_APP_ID)". One thing to double check is the URL Scheme -

CFBundleURLTypes CFBundleURLSchemes fbAPP-ID // **fb** is part of the ID to distinguish this Facebook identifier from others

To troubleshoot, I would recommend starting simple - set your info.plist to have AutoLog, setAdvertiserTracking, and AdvertiserIDCollection enabled. Comment out your checking logic for iOS 14 ATT for now.

I would have "ApplicationDelegate.initialize() return true" after "ApplicationDelegate.shared.application( application, didFinishLaunchingWithOptions: launchOptions )",

which is at end of func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

Pick a screen that upon viewDidLoad() would call:

AppEvents.logEvent(.viewedContent) //try standard Event AppEvents.flush()

I would also check that your graph API call (behind the scene request from logEvent) works from your Terminal:

curl -i -X POST "https://graph.facebook.com/{app-id}/activities ?event=MOBILE_APP_INSTALL &application_tracking_enabled=0
&advertiser_tracking_enabled=0
&advertiser_id={advertiser-tracking-id}

Adjust parameters accordingly to get "success" as a response. It is just checking if your app-id and tracking-id values are valid.

This is the Swift process I went through to reduce the # of variables involved and to account for the different components of this iOS SDK workflow. Hope it helps.

julien-tamade commented 3 years ago

Tip for anybody not getting test events in events manager even while being logged in to facebook app: Make sure you have tracking enabled on the Facebook app too. My tracking for facebook app was turned off but once i turned it on i started to get the events.

ryan-so commented 3 years ago

@julien-tamade thanks this worked for me. Finally seeing data on Test Events!

KylinChang commented 3 years ago

Close the task as it's not a bug of FB SDK.

SonChanthem commented 3 years ago

@SonChanthem - I'm curious if you have actual aliases set up or they are just placeholders in lieu of your actual values for this forum thread - "$(FB_APP_ID)". One thing to double check is the URL Scheme - CFBundleURLTypes

CFBundleURLSchemes

fbAPP-ID // fb is part of the ID to distinguish this Facebook identifier from others

To troubleshoot, I would recommend starting simple - set your info.plist to have AutoLog, setAdvertiserTracking, and AdvertiserIDCollection enabled. Comment out your checking logic for iOS 14 ATT for now.

I would have "ApplicationDelegate.initialize() return true" after "ApplicationDelegate.shared.application( application, didFinishLaunchingWithOptions: launchOptions )",

which is at end of func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

Pick a screen that upon viewDidLoad() would call:

AppEvents.logEvent(.viewedContent) //try standard Event AppEvents.flush()

I would also check that your graph API call (behind the scene request from logEvent) works from your Terminal:

curl -i -X POST "https://graph.facebook.com/{app-id}/activities ?event=MOBILE_APP_INSTALL &application_tracking_enabled=0 &advertiser_tracking_enabled=0 &advertiser_id={advertiser-tracking-id}

Adjust parameters accordingly to get "success" as a response. It is just checking if your app-id and tracking-id values are valid.

This is the Swift process I went through to reduce the # of variables involved and to account for the different components of this iOS SDK workflow. Hope it helps.

Hi @guerri-17 ,

For FB_APP_ID I've set actual value. This "$(FB_APP_ID)" is just my placeholder and also set correct value to URL Scheme -> CFBundleURLTypes

In info.plist file I had set FacebookAutoLogAppEventsEnabled with True value. In func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool add the following code without request to ATT prompt anymore

ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
Settings.isAutoLogAppEventsEnabled = true
Settings.setAdvertiserTrackingEnabled(true)
Settings.isAdvertiserIDCollectionEnabled = false
ApplicationDelegate.initialize()

I used this setting to enable console log Settings.enableLoggingBehavior(.networkRequests). The response in console is success with code 200

Response Body:
(
        {
        body =         {
            success = 1;
        };
        code = 200;
    }
)

But event still didn't showing up on Test Events panel.

Noted: I also enabled tracking permission on Facebook App follow suggestions of @julien-tamad.

guerri-17 commented 3 years ago

@SonChanthem - Hi, KylinChang has closed this thread. To be transparent, my events are showing up in the Overview tab and not in the Test Events tab. May be because we have only 1 prod app with 1 prod Apple App ID.
If you have AutoLog, AdvertiserTracking, and AdvertiserCollectionID set to True in info.plist, you don't need to set them in AppDelegate.swift. If you are using ATT prompt, then you would need to override these values based on user's response.

But for debugging, just use your settings from info.plist. I have AdvertiserIDCollection on, because I need to work on SKAN next. I don't know if it can be off for Event Tracking. Rather relying on auto events tracking, do you have a screen that upon viewDidLoad calls on AppEvents.logEvent(.viewedContent), a standard event?

Did you try the curl call? I also see this in the overview tab:

Screen Shot 2021-07-22 at 11 26 19 PM

Not sure what else I can share.

grashupfer99 commented 3 years ago

After thoroughly reading through everyone's suggestions and commentaries above, I've come up with the following configuration, and I confirm that events are displayed in Test Events and later in Overview.

AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      
        ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        // Logging Behavior 
        Settings.enableLoggingBehavior(.appEvents)
        Settings.enableLoggingBehavior(.networkRequests)
        Settings.enableLoggingBehavior(.developerErrors)
        Settings.enableLoggingBehavior(.graphAPIDebugInfo)
        Settings.enableLoggingBehavior(.accessTokens)
        // Settings
        Settings.isAutoLogAppEventsEnabled = true
        Settings.setAdvertiserTrackingEnabled(true)
        Settings.isAdvertiserIDCollectionEnabled = true
        
        requestTracking()
        
        return true
    }


func requestTracking(){
            if #available(iOS 14, *) {
                ATTrackingManager.requestTrackingAuthorization(completionHandler: { (status) in
                    switch status{
                    case .authorized:
                        Settings.setAdvertiserTrackingEnabled(true)
                        break
                    case .denied:
                        Settings.setAdvertiserTrackingEnabled(false)
                    default:
                        break
                    }
                })
            }
    }

Facebook related config in my plist file:

  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>fb[FACEBOOK_APP_ID]</string>
      </array>
    </dict>
  </array>
  <key>FacebookAdvertiserIDCollectionEnabled</key>
  <true/>
  <key>FacebookAppID</key>
  <string>[FACEBOOK_APP_ID]</string>
  <key>FacebookAutoLogAppEventsEnabled</key>
  <true/>
  <key>FacebookClientToken</key>
  <string>[FACEBOOK_CLIENT_TOKEN]</string>
  <key>FacebookDisplayName</key>
  <string>[FACEBOOK_DISPLAY_NAME]</string>
  <key>LSApplicationQueriesSchemes</key>
  <array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
  </array>
  <key>NSUserTrackingUsageDescription</key>
  <string>Purpose text string here.</string>

Sample event example:

    func emitTestEvent(){
        let ev = "myTestEvent”
        let eventName: AppEvents.Name = AppEvents.Name(rawValue: ev)
        AppEvents.logEvent(eventName)
    }

I've tested on a real iPhone device (Software Version: 14.5.1). I ran a facebook app in background along with my app. Also backing up @julien-tamade's commentary that tracking should be enabled on both apps (facebook app and your app on which you're testing events). You can enable it manually from app's settings > Allow Tracking > On

You should double-check your app’s iOS platform configuration. Especially, if your facebook app's bundle ID matches your app.

Then in the advanced settings, check Advertising Accounts, it should be explained in these docs. All of my events started firing after I updated my Ad Account ID and Business Manager ID.

Test events

test events

Overview

overview tab
SonChanthem commented 3 years ago

@guerri-17 , @grashupfer99 , Hi

May I know do you login with Facebook and with your device? and did you enable permission for tracking on Facebook App?

Thanks.

SonChanthem commented 3 years ago

@KylinChang Hi,

You've closed this issue because of comments mentioned some tip to enable Tracking permission from Facebook app. As my opinion I don't think it correctly at all. Why SDK need enable permission on Facebook to success record event from app? and one more thing we can't force user to enable that permission. May you help to more detail about this case of Closed this issue?

So if FB SDK can improve this part, it is our best appropriate.

Thanks.

grashupfer99 commented 3 years ago

@guerri-17 , @grashupfer99 , Hi

May I know do you login with Facebook and with your device? and did you enable permission for tracking on Facebook App?

Thanks.

Yes, I had a facebook app running in background and enabled tracking permissions like @julien-tamade did with requestTracking here.

I don't think it's an issue with the SDK itself, the docs could be more informative. Perhaps, we should put our efforts toward creating a sample boilerplate project for this issue #1574

@SonChanthem I previously got stuck on getting code = 200; from a response body, the response was coming fine but events wouldn't show in the event manager. Try going over the second step, it helped me.

SonChanthem commented 3 years ago

1574

@grashupfer99 Hi,

So could you help to confirm on your project is your event record correctly? in case we go to Device Setting -> Facebook -> Allow Tracking turn off IMG_6604

grashupfer99 commented 3 years ago

1574

@grashupfer99 Hi,

So could you help to confirm on your project is your event record correctly? in case we go to Device Setting -> Facebook -> Allow Tracking turn off IMG_6604

I've updated my configuration for clarity.

@SonChanthem, You should switch on Allow Tracking setting on both apps.

SonChanthem commented 3 years ago

1574

@grashupfer99 Hi, So could you help to confirm on your project is your event record correctly? in case we go to Device Setting -> Facebook -> Allow Tracking turn off IMG_6604

I've updated my configuration for clarity.

@SonChanthem, You should switch on Allow Tracking setting on both apps.

@grashupfer99, Yes, I do. Unless Facebook switch on to Allow Tracking setting can display event in Events Manager correctly. I'm so wonder why SDK required that option from Facebook App? As we are separated app and our app also use FB SDK. If it's like that we are mostly failed to get event tracking due to user rarely to allow tracking on Facebook App.

Anyway thank you @grashupfer99 for your clarify.

guerri-17 commented 3 years ago

@grashupfer99, @SonChanthem - this may muddy our understanding of Facebook SDK so far but I have not seen an ATT prompt within Facebook app so on my device -> Settings -> Facebook, I have no entry for "Allow Tracking" at all. Yet as long as Facebook is in background, I see my events in the Overview tab for my prod app but never in Test Events tab.

I have a separate test app but it has no "Authorized Ad Account IDs", is that why I see no Events at all from it?

It would be bad to use Facebook SDK which requires "Allow Tracking" for both a non-Facebook app and an active Facebook app for logEvent to work. This requires too much instruction or expectation from user. Thank you both.

ZArez22 commented 3 years ago

For all developers trying to implement Facebook SDK for iOS. Today(25th August 2021) morning I started to see eventes...I don't know what happened because I didn't changed anything in a code... Is that anything you changed Facebook?I also see in Overview Tab iOS 14.5 ATE true status rate. I don't see this anytime before...

This is what all I have in code for other developers to getting things works.

[1] Info.plist

CFBundleURLTypes
<array>
  <dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>fbXXXX</string>
  </array>
  </dict>
</array>
<key>FacebookAdvertiserIDCollectionEnabled</key>
<true/>
<key>FacebookAppID</key>
<string>XXXX</string>
<key>FacebookAutoLogAppEventsEnabled</key>
<true/>
<key>FacebookClientToken</key>
<string>CLIENT-TOKEN from FB</string>
<key>FacebookDisplayName</key>
<string>WallPicture</string>
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
<key>FacebookCodelessDebugLogEnabled</key>
<true/>

[2] In ApplicationDidFinishLaunching I have this(I'm not using SwiftUI) ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) Settings.setAdvertiserTrackingEnabled(true) Settings.isAdvertiserIDCollectionEnabled = true That's 3rows is enough. I don't need any initialization or other things...

[3] I don't need to have Facebook app activated/running on my phone nor Facebook Allow Tracking in settings. So I have set it OFF. I DO NEED to have Allow Tracking in my iOS app ON.

Thank you for support. Milan, developera

tehmou commented 3 years ago

Regarding the Facebook Events Manager Test Events tab; to add my 50 cents into this thread of frustrations and insights.

nickangtc commented 3 years ago

https://www.adexchanger.com/mobile/facebook-undercounted-skadnetwork-conversions-for-iphone-12-users-since-february/

ironmanalex commented 3 years ago

Hi great community,

does anyone know how to solve this? We would be willing to pay for a consultation call, we are struggling so much with this :(

thank you.

You can email us here: isaiahturnermyers@gmail.com

Thanks in advance to ANYONE :)

ZArez22 commented 3 years ago

It’s really a problem of Facebook SDK. We also have problem to see mobile_installs?Cause Facebook SDK send Advetisiement identifier 000000-0000

S pozdravem

Milan Zářecký - umělecký fotograf +420 777 88 99 27 http://www.zarecky.com http://www.zarecky.com/ "Myslete na přírodu. Skutečně potřebujete vytisknout tento e-mail?" "Before printing, think about enviroment."


On 14 Sep 2021, at 00:01, ironmanalex @.***> wrote:

Hi great community,

does anyone know how to solve this? We would be willing to pay for a consultation call, we are struggling so much with this :(

thank you.

You can email us here: @. @.> Thanks in advance to ANYONE :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/facebook/facebook-ios-sdk/issues/1667#issuecomment-918610857, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARJ3OCMGJ4M2VHMSAYCKRETUBZYE7ANCNFSM4YJJOT4A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

af-obodovskyi commented 3 years ago

Tip for anybody not getting test events in events manager even while being logged in to facebook app: Make sure you have tracking enabled on the Facebook app too. My tracking for facebook app was turned off but once i turned it on i started to get the events.

This one really helped, I have spent whole 2 days to fixing this up! My credits!

al-muammar commented 2 years ago

Hi @grashupfer99, I'm unable to see activate app in the events. Do you have a minimal project that is able to reproduce the behaviour you posted?

matte5031 commented 2 years ago

Hello, the only question I have is. Will I be able to track app purchases so that my facebook ads can optimize for purchase without having to ask and get consent from the user to "track them"? If yes, how can that even be good or reliable since only 20% accept to be tracked. Hence, 80% of the purchases will be missed and fb won't be able to optimize corretly and ROAS will not be correct in ads manager since purchases from people who don't allow to be tracked won't be seen, right???

jacobsapps commented 2 years ago

We've been trying to get this working for 2 months before I found this thread.

Based on reading here, and experimenting myself, I was only able to detect events when:

  1. My phone enabled requests for advertiser tracking
  2. I was logged into the FB app with advertiser tracking enabled
  3. In my app, ATTrackingManager.requestTrackingAuthorization is called and status == .authorized
  4. And subsequently setting Settings.shared.isAdvertiserTrackingEnabled = true

What I need to know is:

  1. Is there a way to track app installs without asking for tracking permission? I have a hunch this will cripple our activation rate if we ask our users to track them. Just tracking installs would be a fair compromise if it means we don't need to request permissions. This has to be possible, because all our other advertisers (Reddit, Google) worked without requesting permission through SKAdNetwork.
  2. Is there a way to get any other event data without requesting tracking permissions? We don't understand why Mixpanel or Firebase allows us to send simple analytics events but Facebook needs us to track our users.

Thanks in advance to anyone who can respond.

appcornerit commented 2 years ago

Hi, I'm not sure if it helps, I start seeing events after completing the connection of the data origin process by sending me an email with the instructions. Isn't weird enough?

h4z4rd0uSm1ke commented 2 years ago

I've also noticed custom events showing up in Overview section with filter "All Events" or "Custom Events" but not in the real time section.

ggirotto commented 2 years ago

Why is so difficult to Facebook provide a SIMPLE guide about the impacts and actions needed with new Apple ATT? When ATT request is necessary? What events are impacted if not requesting ATT?

jiafeiinfinit commented 2 years ago

Hi Did anyone resolve this issue? we get the same issue here. the app event does not show on the dashboard with the error message - Not receiving Events via Facebook iOS SDK

FBSDK version : 12.2.1 IOS version: 14.8.1

h4z4rd0uSm1ke commented 2 years ago

Just to contribute to this thread. I can confirm that although events were not showing up in the real time section nor even in the Overview section, once we published our app in the Apple Store, events are now showing up in the Overview section, although there seemed to be a delay of 1-2 days since they all started showing correctly.

dreampowder commented 2 years ago

Hi everyone, everything is working except 'app install' seems to be 'inactive'. does anyone with the similar results have a solurion?

erikmillergalow commented 2 years ago

I'm having trouble parsing through the FB docs and convos around this, can anyone confirm/deny that you can track app installs on iOS without asking for tracking permission?

The only event we want to track is app installs from FB ads, I'm not sure it's worth it if we have to prompt the user for ATT permissions.

ggirotto commented 2 years ago

In my case we haven't asked for ATT and the app installs are being tracked in iOS

SRReddy411 commented 2 years ago

After thoroughly reading through everyone's suggestions and commentaries above, I've come up with the following configuration, and I confirm that events are displayed in Test Events and later in Overview.

AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
      
        ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
        // Logging Behavior 
        Settings.enableLoggingBehavior(.appEvents)
        Settings.enableLoggingBehavior(.networkRequests)
        Settings.enableLoggingBehavior(.developerErrors)
        Settings.enableLoggingBehavior(.graphAPIDebugInfo)
        Settings.enableLoggingBehavior(.accessTokens)
        // Settings
        Settings.isAutoLogAppEventsEnabled = true
        Settings.setAdvertiserTrackingEnabled(true)
        Settings.isAdvertiserIDCollectionEnabled = true
        
        requestTracking()
        
        return true
    }


func requestTracking(){
            if #available(iOS 14, *) {
                ATTrackingManager.requestTrackingAuthorization(completionHandler: { (status) in
                    switch status{
                    case .authorized:
                        Settings.setAdvertiserTrackingEnabled(true)
                        break
                    case .denied:
                        Settings.setAdvertiserTrackingEnabled(false)
                    default:
                        break
                    }
                })
            }
    }

Facebook related config in my plist file:

  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>fb[FACEBOOK_APP_ID]</string>
      </array>
    </dict>
  </array>
  <key>FacebookAdvertiserIDCollectionEnabled</key>
  <true/>
  <key>FacebookAppID</key>
  <string>[FACEBOOK_APP_ID]</string>
  <key>FacebookAutoLogAppEventsEnabled</key>
  <true/>
  <key>FacebookClientToken</key>
  <string>[FACEBOOK_CLIENT_TOKEN]</string>
  <key>FacebookDisplayName</key>
  <string>[FACEBOOK_DISPLAY_NAME]</string>
  <key>LSApplicationQueriesSchemes</key>
  <array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
  </array>
  <key>NSUserTrackingUsageDescription</key>
  <string>Purpose text string here.</string>

Sample event example:

    func emitTestEvent(){
        let ev = "myTestEvent”
        let eventName: AppEvents.Name = AppEvents.Name(rawValue: ev)
        AppEvents.logEvent(eventName)
    }

I've tested on a real iPhone device (Software Version: 14.5.1). I ran a facebook app in background along with my app. Also backing up @julien-tamade's commentary that tracking should be enabled on both apps (facebook app and your app on which you're testing events). You can enable it manually from app's settings > Allow Tracking > On

You should double-check your app’s iOS platform configuration. Especially, if your facebook app's bundle ID matches your app.

Then in the advanced settings, check Advertising Accounts, it should be explained in these docs. All of my events started firing after I updated my Ad Account ID and Business Manager ID.

Test events test events

Overview overview tab

hi same thing i am follow but in ios 14.8.1 version i can't see my events

i8ramin commented 2 years ago

I'm having trouble parsing through the FB docs and convos around this, can anyone confirm/deny that you can track app installs on iOS without asking for tracking permission?

The only event we want to track is app installs from FB ads, I'm not sure it's worth it if we have to prompt the user for ATT permissions.

exactly this. this is all we want to track as well. do we need to ask user for ATT permissions? if so, then auto tracking app lifecycle events is basically useless, since they fire before user has had a chance to respond to ATT prompt

beaneymidnite commented 2 years ago

Experiencing something similar. To date I have still not managed to use the "Test Events" tab successfully, despite trying everything on this thread.

Additionally, I cannot use the "Configure App Events for iOS 14.5 and later Ad Optimizations" in the dashboard. I send the notification which arrives, tap it, which opens my app, and I wait. Nothing happens in the dashboard. It hangs and then gives a "Can't connect" error, with some vague "turn it off and on again"-type instructions.

This needs attention IMO.

erikmillergalow commented 2 years ago

I was eventually able to get app install events to fire without requesting ATT but it took a lot of trial/error, slogging through multiple versions of Meta docs, and github issues.

This might not be 100% comprehensive but I had to add this to AppDelegate.m in didFinishLaunchingWithOptions:

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBAEMKit/FBAEMKit.h>

...

[[FBSDKApplicationDelegate sharedInstance] application:application
                         didFinishLaunchingWithOptions:launchOptions];
  [FBSDKApplicationDelegate.sharedInstance initializeSDK];
  [FBSDKSettings.sharedSettings setAdvertiserTrackingEnabled:YES];
  [FBSDKSettings.sharedSettings setAutoLogAppEventsEnabled:YES];

and this to openUrl:

  [FBAEMReporter configureWithNetworker:nil appID:@YourFBAppID];
  [FBAEMReporter enable];
  [FBAEMReporter handleURL:url];
  if ([[FBSDKApplicationDelegate sharedInstance] application:app openURL:url options:options]) {
    return YES;
  }

  if ([RCTLinkingManager application:app openURL:url options:options]) {
    return YES;
  }

This to Info.plist:

    <key>FacebookAppID</key>
    <string>YourFBAppID</string>
    <key>FacebookClientToken</key>
    <string><YourClientToken></string>
    <key>FacebookDisplayName</key>
    <string>YourFBAppName</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fb-messenger-share-api</string>
    </array>

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fbYourFBAppID</string>
            </array>
        </dict>
                 ....
    </array>
    <key>CFBundleVersion</key>

The URL scheme is added in addition to any others you already have there. Something that tripped me up initially was leaving out the 'fb' at the beginning of the app ID in the URL scheme.

As others have mentioned, be sure to be signed in to the FB app (using the same account that you use for FB Business) and have it open in the background while first trying to view test events in the event manager.

beaneymidnite commented 2 years ago

@erikmillergalow - thanks for the response, I'm a bit concerned about this line though:

[FBSDKSettings.sharedSettings setAdvertiserTrackingEnabled:YES];

Is this not you telling Facebook that the user has consented to advertiser tracking (in other words, consenting to ATT)?

erikmillergalow commented 2 years ago

@beaneymidnite I could be wrong but my understanding is that ATT is only needed when tracking data that will identify the user, but that the FB app install event uses SKAdNetwork to link installs to ads anonymously.

See here under the first question in the FAQs: https://developer.apple.com/app-store/user-privacy-and-data-use/#attributing-app-installations

beaneymidnite commented 2 years ago

Ah okay, you're just doing SKAdNetwork. I'm also interested in Aggregated Event Measurement, which relies on other events being sent via the Facebook SDK.

Interestingly, your tips did get me one step further in the chain - I can now "set up" AEM in the dashboard under the "Configure App Events for iOS 14.5 and later Ad Optimizations" section, but it's now telling me there's no events in the last 90 days, and to check the overview tab (which has events coming in from the last 2 days, let alone 90!).

ahtokca commented 2 years ago

it is unbelievably hard to make events appear at Events Manager. Spent 2 days with no success. I see events being sent via adb logcat and iPhone console however Event Manager/Test Events shows nothing. All of that gives me no confidence that FB treats the app data seriously :(

khushbujilka22 commented 2 years ago

@beaneymidnite could you please help me, how you done with Configure App Events for iOS 14.5 and later Ad Optimizations ?

I'm getting this error "We're unable to get a conversion from your app. There could be a problem with the integration of the Facebook SDK in your iOS mobile app.".

imbimp commented 2 years ago

Keeping this thread alive as spent months trying to get this to work. Tried everything above, still getting no events despite seeing them come out of the app in network requests.

DonTharaka commented 2 years ago

Facebook documentation on app events is very vague. It does not contain any information about ATTrackingManager which is necessary to track events. First follow all steps in the documentation. Below are the steps I have taken to successfully connect app events (iOS 15):

  1. Info.Plist Screen Shot 2022-08-11 at 10 44 47 am

  2. SceneDelegate

Screen Shot 2022-08-11 at 10 50 43 am

Screen Shot 2022-08-11 at 11 05 33 am

Screen Shot 2022-08-11 at 10 48 40 am

This will bring up the following pop up:

Screen Shot 2022-08-11 at 10 58 05 am

  1. In your viewcontroller:

Screen Shot 2022-08-11 at 10 52 39 am