Search code examples
iosswiftmobilegoogle-analyticsanalytics

How to set up event tracking with multiple views in google analytics for mobile app (iOS)


Just started using google analytics for my current app.

Let's say i have three kinds of views, for example animals, flowers and birds. I want to send the id of the object to google analytics respective to the view type when user clicks on that object.

I created these three views(animals, flowers and birds) in my app(Property) in Google Analytics

in each view the code looks like below

override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(true)
        let tracker  = GAI.sharedInstance().defaultTracker
        tracker.set(kGAIScreenName, value: "Birds View")
        tracker.send(GAIDictionaryBuilder.createAppView().build())
    }
func birdViewClicked(){
        let tracker  = GAI.sharedInstance().defaultTracker
        tracker.set(kGAIScreenName, value: "Birds View")
        tracker.send(GAIDictionaryBuilder.createEventWithCategory("Bird", action: "Viewed", label: "Bird123", value: nil).build())
        tracker.set(kGAIScreenName, value: nil)
    }

So should there be any mapping done between the kGAIScreenName and views in Google Analytics? Do i need to add filters or goals for the view? Currently i am getting all objects under "All Mobile App Data" view

Thanks in advance


Solution

  • "All Mobile App Data" is nothing more than the heading Google Analytics uses for your mobile stats. You need to click on this in GA and it will take you to dashboard views. There you can use the defaults or set up your own custom dashboards that show / track the metrics you are interested in. You will see your views listed under 'screens' and your events listed under 'events'. You can also add custom dimensions as per https://developers.google.com/analytics/devguides/collection/ios/v3/customdimsmets