Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Google Analytics for iOS without .plist file

According to Google's documentation (Analytics for iOS), they want you to download some auto-generated .plist file to configure your app. Unfortunately, I have multiple report suites (Debug, Release) and need to switch dynamically depending on the build. So I'm trying to do one of two things:

  1. Is there a way to totally ditch the .plist file and set all the configs dynamically? What values would one need?

-OR-

  1. Can I alter the values in the Google .plist file to use variables from my project's User-Defined Build Settings? I tried adding one named GOOGLE_ANALYTICS_ID and referencing it by ${GOOGLE_ANALYTICS_ID} in the Google .plist file, but it doesn't substitute the value like how I would expect it to.

How have you dynamically instructed your app to send to different report suites depending on whether your app is Debug or Release?

like image 464
John D. Avatar asked Oct 28 '15 23:10

John D.


People also ask

Does Google Analytics work on iOS?

Stay organized with collections Save and categorize content based on your preferences. Use our iOS sample app to see how Analytics works, or add Analytics to your existing app.


1 Answers

You should be able to ditch the .plist file and setting it up like so:

#import "GAI.h"
...
GAI *gai = [GAI sharedInstance];
[gai trackerWithTrackingId:@"your GA id"];
gai.trackUncaughtExceptions = YES;  // optional
gai.logger.logLevel = kGAILogLevelVerbose;  // optional - remove for release

Don't use the GGLContext stuff since that's trying to get parameters from the -plist file.

like image 126
MickeDG Avatar answered Oct 13 '22 02:10

MickeDG