Sitata / titanium-google-analytics

Google analytics for Appcelerator Titanium
MIT License
92 stars 47 forks source link

Enables IDFA Collection #27

Closed memotoro closed 1 year ago

memotoro commented 9 years ago

Hello. I modified both proxies (Java Proxy for Android and Objective C for OS) to allow developers to change the value of the property IDFA Collection (identifier for advertisers). I modified the files for the XCode project called project.pbxproj and module.xcconfig in order to include the Google Analytic Library and the Advertising Framework as they are required. These changes are part of the Google Analytics configuration steps for iOS. Please have a look and let me know any potential issue or fix to be done. Regards

jpriebe commented 9 years ago

There is a corresponding change that should be made on the android size of the house:

// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);

// Enable Display Features.
t.enableAdvertisingIdCollection(true);

Details here: https://support.google.com/analytics/answer/2444872?hl=en&utm_id=ad#app

Wouldn't it be better to expose a single method on the tracker object for both platforms so that the resulting javascript would look something like this:

var tracker = GA.getTracker("UA-1234567-8");

// sets allowIDFACollection on ios; calls enableAdvertisingIdCollection() on android
tracker.enableAdvertisingFeatures(true);

tracker.trackEvent({
    category: "Loading",
    action: "cancelled"
});

This keeps the API consistent across ios and android (a pet peeve of mine is Ti modules that have different calls for the two platforms).

memotoro commented 9 years ago

Hello @jpriebe. Thanks for your comments. Actually, that is exactly what I did. I created a single method y both proxies (Java and Objective C) called 'enableIDFACollection' receiving a boolean value. This method activates/deactivates that feature in both platforms. Please have a look to the changes in the commits section and let me know your thoughts about it. Regards

jpriebe commented 9 years ago

D'oh -- somehow I missed the change to the Java file (and I missed it in your initial comment). Sorry about that.

I really think that the name of the method is too iOS-centric. I believe that IDFA is an iOS-only term. Conceptually IDFA is the same kind of thing as android's advertising ID, but I would avoid naming a cross-platform API method with a name that is biased toward one of the two platforms.

"Advertising features" seems to be the term that the GA term gives to the umbrella concept that covers both platforms.

Just my $0.02. I would be happy to use your changes either way, but in the long run, I think that users will find it easier to understand if the naming is more neutral and aligned with GA terminology.

memotoro commented 9 years ago

Hello. Following the suggestion made by @jpriebe, I renamed the method to be non-iOS centric. I totally agree with the fact that the name of the method was iOS centric. The method now is called 'enableAdvertisingFeatures' for both platforms (Android and iOS). Regards

astjohn commented 9 years ago

@memotoro, This is great work. Thank you and sorry for my late reply. I've been busy and haven't had much time for open source stuff. I have one question though regarding the IDFA stuff. Will Apple reject an app that has the IDFA library linked, but actually has the feature turned off? A while back, there were issues involving this aspect. I made some reference to this fact in this comment regarding a separate issue.

What are everyone's thoughts on this matter? Does anyone know if an app will still be accepted if bring this in?

jpriebe commented 9 years ago

@astjohn: you know a lot more about this than I do, and I appreciate your caution on this. Getting a rejection from Apple for something like this could really slow down a project.

If the app uses advertising (like maybe it uses ti.dfp), then it seems like using the IDFA with google analytics is only going to improve the data gathered by GA. As long as using the IDFA doesn't cause scary warnings to pop up (does it?), then there is no real downside to the app developer to turn on advertising features.

However, if the app does not use advertising, then according to apple, it can't use the IDFA. Therefore, in such an app, you would not be able to enable advertising features for GA. To your point, you would then have libAdIdAccess.a linked up in an app that doesn't use the IDFA. The app developer would check "no" for the IDFA question while submitting the app. But basic code analysis would find the IDFA calls within libAdIdAccess.a, right? So I guess there is a chance that this could trigger rejection.

Stupid question -- can you package two versions of the module, one with and one without libAdIdAccess.a ? That certainly isn't going to make it easier to use the module, but you could have the default version of the module ship without libAdIdAccess.a, and if a developer needs to use the advertising features, he can switch to the IDFA-enabled version of the module.

Titanium's module framework probably doesn't provide for anything more elegant than this, does it?

astjohn commented 9 years ago

@jpriebe - Not a stupid question at all and I was thinking about the two branch approach as well. I'm going to investigate a bit more about the rejection / IDFA stuff. It would definitely help if, in the mean time, someone could submit an app that has this commit without directly using it and see if it is rejected or not.

memotoro commented 9 years ago

Hello. I'll let you know as soon as I have some news about the rejection or approval of our app on Apple Store. Regards.

astjohn commented 9 years ago

@jpriebe The official word back from Apple is that if the app doesn't use IDFA stuff, and you answer as such when submitting it for review, then Apple might reject it. If that's the case, it might be best to have two branches and two release versions for ios. Still waiting to hear from @memotoro to see if that app passes.

soumyakantikar commented 9 years ago

I know it might be too early to respond before @memotoro gets back, but from my initial study of the issues reported by developers related to this is that, if the application bundle had IDFA libraries and the application was not using it, then the applications were rejected. For this reason, GA split it up in two different libraries so that developers who do not require IDFA can ignore and use the correct library. But like I mentioned, it is too early to say, but just my thoughts on the same. I agree with @astjohn that maintaining two different branches seems more clean.

iRonin commented 9 years ago

@memotoro Any news?

memotoro commented 9 years ago

Hello everybody. Sorry for the late reply. We are preparing our app to be submitted to the Apple store during this week. As soon as I have some news about the approval or rejection of our app due to this advertising feature, I'll let you know. Regards.

memotoro commented 9 years ago

Hello Everybody.

Our app was approved by Apple and is now in the App Store. Our app uses the IDFA for tracking the number of installation through Google Analytics. We don't use/include Adds in our app. The options that we chose during the app submission were as follows:

For the question "Does this app use the Advertising Identifiers (IDFA)?" We clicked "Yes". This action triggers extra questions to be answered.

For the question "This app uses Advertising Identifiers to (select all of apply)". We only selected "Attribute this app installation to a previously served advertising".

The option "Limit Add tracking setting in iOS" was selected as well.

Regards

iRonin commented 9 years ago

It worked for our baby activity tracking app for nursing mothers too. Thanks!

astjohn commented 9 years ago

@memotoro Thank you for the update. It's probably still best if we carry two branches, one with IDFA and one without and developers will have to notify Apple when using IDFA or not. Otherwise, they might be rejected by Apple.

argum commented 7 years ago

Hi to all. Great job with this improvment on the analytics-google module.

I have a problem while compiling an iOS app to a real device (no problem using simulator), related maybe to the libanalytics.google.a library.

When I compile the module for iOS i saw an erorrs related to "no such file or directory" for two libraries (libz.dylib and libsqlite.3.0.dylib). I have found this libraries un /usr/lib/ so I have copied this two libs to the folder where the build looks. (i don't remember the full path). Because in the folder where builder looks, there are only "tdb" files, not dylib (but exists libsql.3.0.tdb and libz.tdb).

Titanium gives me a linker error, xcode have a detailed list of error. The errors are shown below: Titanium: (build 4.8.1.201612050850 sdk: 6.0.3) BUILD FAILED [ERROR] : The following build commands failed: [ERROR] : Ld build/Intermediates/.build/Debug-iphoneos/.build/Objects-normal/armv7/****normal armv7 [ERROR] : (1 failure)

Xcode (8.0 8A218a)

Showing Recent Messages "_inflate", referenced from: +[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libanalytics.google.a(GAICompressionUtil.o) "_deflate", referenced from: +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libanalytics.google.a(GAICompressionUtil.o) "_inflateEnd", referenced from: +[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libanalytics.google.a(GAICompressionUtil.o) "deflateInit2", referenced from: +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libanalytics.google.a(GAICompressionUtil.o) "inflateInit2", referenced +[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libanalytics.google.a(GAICompressionUtil.o) "_deflateEnd", referenced from: +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libanalytics.google.a(GAICompressionUtil.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Could you please help me to solve this problem? Could be related to this two libraries that the builder does not found in the right folder? Thanks!