firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.47k stars 1.43k forks source link

Firebase does not attribute SKAdNetwork install? #7426

Closed jjuansan closed 1 year ago

jjuansan commented 3 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Firebase does not track installs unless I call Analytics.setAnalyticsCollectionEnabled(true) which isn't mentioned in the SDK instructions and should not be needed now that we have SKAdNetwork to track install sources.

Steps to reproduce:

I follow the instructions in the firebase console for the SDK Setup image

Registering my app, placing the plist, adding the SDK - follow the tutorial religiously

The first issue arises on Step 4, adding the initialization code. The instructions tell me to add 'Firebase/Analytics' to my podfile, but they want me to import Firebase. Firebase doesn't seem to get installed using the pods, but after 3 hours of searching I found a 2-year-old Stackoverflow thread to instead import FirebaseCore which DOES indeed get installed using the tutorial. I can now add FirebaseApp.configure() to my didFinishLaunchingWithOptions - so far so good. No idea why the integration tutorial doesn't mention that or if me and hundreds of others on Stackoverflow are doing something wrong.

The next roadblock happens on Step 5 - it's stuck on Checking if the app has communicated with our servers. You may need to uninstall and reinstall your app. On another Stackoverflow thread I've found someone recommending putting the app to the background and waiting an hour and repeating that until something shows up. Unfortunately that doesn't do anything. I repeat the whole integration and run into the same issues. I double-check the .plist (that I haven't changed, I kept it in the original state since I first downloaded it from the tutorial) and start looking at what other functions the Analytics object has. I find Analytics.setAnalyticsCollectionEnabled(true) and magically, everything is working.

Questions so far: is this the expected behavior? I don't know what the tutorial's purpose would be if it leaves out this step.

Especially since it's supposedly enabled by default: image

Again, I can be wrong about everything here, but deliberately setting it to "true" was the only way to finally make something show up in the realtime and debug dashboard.

In the .plist I found <key>IS_ANALYTICS_ENABLED</key> <false></false> - is this referring to this setting? Why is it false on download?

Now to my next comment: Is setAnalyticsCollectionEnabled needed to track install sources? I just want to get Google Ads and YouTube ads working, nothing fancy. The fact that it appears to be false by default makes me wonder if I have to get user consent first. But that, to me, invalidates the purpose of the SkAdNetwork integration. https://developer.apple.com/app-store/user-privacy-and-data-use/ claims:

Frequently Asked Questions
Do I need to ask for user permission to track in order to use SKAdNetwork?
No. SKAdNetwork allows advertising networks to attribute app installations while preserving user privacy, so you do not need to use the AppTrackingTransparency prompt. However, if your app includes any instances of tracking, you will need to receive the user’s permission through the AppTrackingTransparency framework to track them or access their device’s advertising identifier.

So making Firebase behave the way it's iOS 14 privacy compliant is either impossible, or deeply underdocumented. I've used Firebase Database services for years and found the integration almost magical but it's beyond me how something seemingly simple can be so hard/unintuitive/impossible to implement.

tl;dr Firebase doesn't behave the way it's documented and no integration tutorial can tell me how I can track installs without tracking a user's every step. I need to track the install source to run Google Ads but Firebase doesn't seem to support the non-intrusive SkAdNetwork integration. Instead, to me it looks like you can either enable the whole tracking infantry or have Firebase completely silent, there is no inbetween.

I am so much hoping that this is a misunderstanding and I am missing something here but I don't know where else to search but in the integration tutorials written by Google. I only want to see if a new install comes from Google Ads/YouTube Ads. Is this even possible?

google-oss-bot commented 3 years ago

I found a few problems with this issue:

morganchen12 commented 3 years ago

Hey @jjuansan,

they want me to import Firebase. Firebase doesn't seem to get installed using the pods

The Firebase module is defined in the podspec and includes a header that conditionally includes all other Firebase pods if they're available. In our samples we use import Firebase instead of importing each Firebase pod manually to reduce the number of imports. It doesn't provide anything beyond convenience. There may be something strange going on in your build settings if you're unable to import this module.

I find Analytics.setAnalyticsCollectionEnabled(true) and magically, everything is working.

Questions so far: is this the expected behavior?

This is definitely a bug. Analytics is enabled by default and explicitly setting this value to true should not affect Analytics behavior unless it was explicitly set to false in the past.

In the .plist I found IS_ANALYTICS_ENABLED - is this referring to this setting? Why is it false on download?

This is an older flag that serves a now-deprecated Google Analytics product and doesn't affect Firebase Analytics. Plist flags for disabling Firebase Analytics can be found in this doc.

you can either enable the whole tracking infantry or have Firebase completely silent, there is no inbetween.

Without requesting the user's IDFA, Firebase will only send some basic app usage statistics like time spent in foreground.

jjuansan commented 3 years ago

Thank you for your elaborate response, much appreciated.

About my potentially incorrect build settings - can my import FirebaseCore workaround negatively affect my situation? Or does it basically result in the same behavior as the tutorial's import Firebase as long as the compiler does not complain?

So, if I now understood correctly, the normal FirebaseApp.configure() does NOT need the user's consent as it does not collect personal data, and should be enough to attribute SKAdNetwork tracking is that correct?

I apologize for my false assumptions about the default behavior - how can I contribute to help fixing this issue? I have uninstalled and reinstalled the app numerous times.

Does setAnalyticsCollectionEnabled() affect the app's standing with the GDPR if I don't employ any methods to specifically identify users? Or is user consent already needed for that function? If it doesn't collect any personal data and user consent is not required I, for now, could just set it to true on first app launch.

Could ANY local settings on my devices affect this situation? I have tried on numerous devices now and I'm never getting a result. Only the app launches with a build that explicitly set setAnalyticsCollectionEnabled(true) bring data to the DebugView.

morganchen12 commented 3 years ago

About my potentially incorrect build settings - can my import FirebaseCore workaround negatively affect my situation? Or does it basically result in the same behavior as the tutorial's import Firebase as long as the compiler does not complain?

The errant behavior you're experiencing is almost definitely not caused by which import you use. If your project compiles, it's probably fine.

So, if I now understood correctly, the normal FirebaseApp.configure() does NOT need the user's consent as it does not collect personal data, and should be enough to attribute SKAdNetwork tracking is that correct?

There seems to be some misunderstanding here; FirebaseApp is just a representation in your app of what a Firebase application is (one FirebaseApp per Firebase project), and does not require collection of data. If you initialize a FirebaseApp and then don't make any other Firebase calls, Firebase will not collect any data unless you've explicitly included a Firebase SDK that automatically collects telemetry (Analytics, Performance).

I apologize for my false assumptions about the default behavior - how can I contribute to help fixing this issue? I have uninstalled and reinstalled the app numerous times.

Analytics is closed-source, so you may have to wait for an official fix.

Does setAnalyticsCollectionEnabled() affect the app's standing with the GDPR if I don't employ any methods to specifically identify users? Or is user consent already needed for that function? If it doesn't collect any personal data and user consent is not required I, for now, could just set it to true on first app launch.

I am not a lawyer, so I cannot answer this question. You can consult our GDPR documentation, which likely does not contain the answer to your specific question.

Could ANY local settings on my devices affect this situation? I have tried on numerous devices now and I'm never getting a result. Only the app launches with a build that explicitly set setAnalyticsCollectionEnabled(true) bring data to the DebugView.

Events won't reliably show up in Debug View unless you explicitly set the Analytics debug parameter. See this doc for more details. It is strange that explicitly setting the data collection to true when it's true by default is causing events to show up reliably in Debug View for you. Can you share your project or a similar sample project?

jjuansan commented 3 years ago

Thank you for the information regarding the import

-

I agree about the "misunderstanding" part: There are 3 different Google Services with overlapping names, there is Analytics (A) which is something different than Firebase Analytics (F). Google Ads warns me that my ad won't run until conversation tracking is set up which should supposedly work under Analytics F yet following the tutorial referred to by Google Ads leads you to analytics.google.com which manages Analytics A which in turn you have to link to Analytics F.

Supposedly, Firebase F can confirm app installation sources using SKAdNetwork that a user doesn't have to consent to, yet the non-Firebase Analytics A SDK instructions referred to by Google Ads are waiting for Firebase F calls that don't happen until you deliberately do setAnalyticsCollectionEnabled(true). This method, you can't confirm or deny the GDPR-compliance of, except for sharing a link that "likely does not contain the answer to your specific question" when the question is about the configure() method that you have to run in any case and the only method that makes the whole framework run to begin with. Of course Google can't make privacy policies for each combinations of use-cases but a privacy documentation on the bare-minimum implementation really is something one could expect from a closed-source framework.

In Google Ads, using the "have questions about the integration?" form to ask about the SKAdNetwork attribution got me a response that referred me to the Google AdMob Mobile Ads SDK, where it shows what SKAdNetworkIdentifier to add to your .plist. However, from my understanding, AdMob was the SDK to let ads run in your own app and has nothing to do with tracking your own app's installs - why is the documentation only there and not also in the Google Ads/ linked Analytics (A or F) instructions? It's like if a car manufacturer had to refer to a manual that talks about motorcycles.

I bow down to anyone who is mentally capable of not being confused by this.

-

Maybe in a few weeks when I can't find any alternatives to Google Ads I will find some time to prepare an example project for you but right now I don't see myself achieving anything here as, so far, this seems to be the most vague and inconsistent stuff I've ever seen, sorry. Even if I was given 2 weeks to implement this I probably wouldn't have made more progress than I did in the last few days, this seems impossible to achieve.

morganchen12 commented 3 years ago

I bow down to anyone who is mentally capable of not being confused by this.

I believe the intended integration is attribution via SKAdNetwork should happen automatically once Firebase Analytics is linked in, but it's not currently due to a bug. The documentation and Google Analytics vs Google Analytics for Firebase things are significant sources of confusion and we'll work on improving those.

shubhnik commented 2 years ago

Facing a similar issue. Not getting attribution for first_open and in_app_purchase conversion events.

timbo-tj commented 1 year ago

So, if I now understood correctly, the normal FirebaseApp.configure() does NOT need the user's consent as it does not collect personal data, and should be enough to attribute SKAdNetwork tracking is that correct?

Is this the case? If I configure FirebaseApp and enable FireabseAnalytics, will SKAdNetwork tracking work properly? Or do we need to go the whole way and request tracking permission from the user using the App Tracking Transparency popup?

We just want to make sure we are able to attribute installs from ads.

timbo-tj commented 1 year ago

https://firebase.google.com/docs/ios/supporting-ios-14#affected-firebase-integrations

This section mentions that :

Analytics event logging, event reporting, and conversion measurement are unaffected, but attribution is impacted if IDFA is not accessible.

So maybe this means we need bring up the App Tracking Transparency popup, gain authorisation, prior to setting up Firebase + Firebase Analytics?

This is all immensely confusing!

timbo-tj commented 1 year ago

Hello just following up if anyone has any idea if we're required to use the App Tracking Transparency dialogue for attribution for work properly?

https://developer.apple.com/documentation/storekit/skadnetwork/

SKAdNetwork APIs are designed to maintain user privacy. Apps don’t need to use App Tracking Transparency before calling SKAdNetwork APIs, and can call these APIs regardless of their tracking authorization status.

It seems like attribution tracking should work correctly without App Tracking Transparency?

But this thread is giving me doubts and I am unsure how to properly verify things are working.

tsunghung commented 1 year ago
  1. By default, you don't need to call Analytics.setAnalyticsCollectionEnabled(true) to make Analytics work. Please try the latest FirebaseAnalytics to see if it works. You can check the analytics quickstart as an example.
  2. As you pointed out, you don't need ATT to have SKAdNetwork work.
  3. Please see SKAdNetwork, there are 3 major participants, ad network, source app, and advertised app. Currently, FirebaseAnalytics would call registerAppForAdNetworkAttribution() when the first_open event is logged. However, the advertised app needs to call updateConversionValue(_:) explicitly if a specific conversion value is desired. Please note the Ad Attributions and Postbacks are sent to the ad network, not FirebaseAnalytics. You need to consult with the ad network to check the advertising effectiveness. (You can also configure the advertised app to receive postbacks.)
timbo-tj commented 1 year ago

Hey Thanks for the reply tsunghung, seems like all should be good on our end then!

timbo-tj commented 1 year ago

Does this mean this issue is resolved? The source problem here was that Firebase does not track installs unless Analytics.setAnalyticsCollectionEnabled(true) was called.

tsunghung commented 1 year ago

Thanks for the confirmation. I would close the issue for now. Please reopen the issue if you still encounter the same problem or create another issue if you encounter other problems, thanks.

timbo-tj commented 1 year ago

Sorry for the confusion, I wasn't confirming anything. I haven't tried it yet. Just based on what you are saying it should be working. (I don't know how to verify campaign attribution is working without actually running a campaign and seeing if it works).

tsunghung commented 1 year ago

I see, how about the original problem? You should be able to track installs without calling Analytics.setAnalyticsCollectionEnabled(true). If that's not the case, please feel free to reopen this issue.

timbo-tj commented 1 year ago

Ill be doing builds at the end of this week and I'll try to test it! Is there an easy way to tell in a development environment if the install was tracked?

tsunghung commented 1 year ago
  1. Enable debug mode
  2. Uninstall your app from the simulator.
  3. From Xcode, run your app. (Xcode should install and launch your app on a simulator.)
  4. From Xcode debug console, you should be able to find first_open.
timbo-tj commented 1 year ago

Thanks for that, I will update when I try it out!

timbo-tj commented 1 year ago

It all appears to be working here.

tsunghung commented 1 year ago

Great, thanks a lot for the confirmation!

timbo-tj commented 1 year ago

Thanks for that, I will update when I try it out!

On Wed, Sep 14, 2022 at 9:40 AM tsunghung @.***> wrote:

  1. Enable debug mode https://firebase.google.com/docs/analytics/debugview#enable_debug_mode
  2. Uninstall your app from the simulator.
  3. From Xcode, run your app. (Xcode should install and launch your app on a simulator.)
  4. From Xcode debug console, you should be able to find first_open.

— Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-ios-sdk/issues/7426#issuecomment-1246058415, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUHLXG5GEME3SCAJ77TWIM3V6EGHLANCNFSM4W7CR26Q . You are receiving this because you commented.Message ID: @.***>