简体   繁体   中英

about google analytics for mobile apps (android or ios)

I am fairly new in Google Analytics in general, so please be patient with me and my questions.

If I am using the Google Analytics for web, by putting in the tracking code in my web header, GA will automatically collect data (visitors, page view, sources, etc)

For mobile app, I need to put the plist (iOS) or json (Android) into the build and compile.

My understanding is that it's not enough just by putting the plist or json file into the app, right?

I would need to implement each and every single thing I want to track. For example, if i want a pageview (screens), then I would need to implement it inside my app code

https://developers.google.com/analytics/devguides/collection/ios/v3/screens

so it's not automatic like in web, where I put the script on header and it works right away.

Is that correct?

I haven't used GA for web, so I can't compare it to GA for mobile.

But I believe you are correct that you need to implement everything you want to track.

It's not too difficult. Using GA 3.11 for iOS, in Swift 3.0, the first thing I do is set up the shared GA instance in my app delegate's didFinishLaunchingWithOptions method:

GAI.sharedInstance().trackUncaughtExceptions = true
GAI.sharedInstance().dispatchInterval = 120
GAI.sharedInstance().logger.logLevel = GAILogLevel.info
GAI.sharedInstance().tracker(withTrackingId: "YOUR GA ID GOES HERE")

To track a screen view, I do this in viewWillAppear of each view controller:

if let tracker = GAI.sharedInstance().defaultTracker {
    tracker.set(kGAIScreenName, value: "YOUR SCREEN NAME GOES HERE")
    tracker.send(GAIDictionaryBuilder.createScreenView().build() as [NSObject : AnyObject])
}

To send an event:

let tracker = GAI.sharedInstance().defaultTracker
tracker?.send(GAIDictionaryBuilder.createEvent(withCategory: "YOUR CATEGORY", action: "YOUR ACTION",  label: "YOUR LABEL", value: NSNumber(integerLiteral: YOURINTEGERVALUE)).build() as NSDictionary as [NSObject : AnyObject])

Setting custom dimensions and sending screen views with dimensions is similar. That's about as far as I've gone with GA.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM