1
votes

I know that there are a lot of questions and answers about google analytics issues, but nothing helps me.

I have installed google with pods

pod 'GoogleAnalytics'

and imported this in bridging header, and use this code in appDelegate

<GoogleAnalytics/GAI.h>
"GAIDictionaryBuilder.h"
guard let gai = GAI.sharedInstance() else {
            assert(false, "Google Analytics not configured correctly")
        }

        GAI.sharedInstance().defaultTracker = gai.tracker(withTrackingId: "UA-109196643-1")
        // Optional: automatically report uncaught exceptions.
        gai.trackUncaughtExceptions = true
        GAI.sharedInstance().dispatchInterval = 20
        GAI.sharedInstance().dispatch { (result) in
            print(result)
        }
        // Optional: set Logger to VERBOSE for debug information.
        // Remove before app release.
        gai.logger.logLevel = .verbose;

here is the logging text

INFO: GoogleAnalytics 3.17 -[GAIBatchingDispatcher hitsForDispatch] (GAIBatchingDispatcher.m:369): No pending hits. INFO: GoogleAnalytics 3.17 -[GAIReachabilityChecker reachabilityFlagsChanged:] (GAIReachabilityChecker.m:161): Reachability flags update: 0X000002

and here is the log when I am logging screen

GoogleAnalytics 3.17 -[GAIBatchingDispatcher persist:] (GAIBatchingDispatcher.m:518): Saved hit: { parameters = { "&_crc" = 0; "&_s" = 9; "&_u" = ".npetoK9L"; "&_v" = "mi3.1.7"; "&a" = 1028296819; "&aid" = "******"; "&an" = Mataam; "&av" = "1.0"; "&cid" = "59cc9c6e-be21-4ac8-b6d9-d3beff894dbf"; "&dm" = "x86_64"; "&ds" = app; "&sr" = 1242x2208; "&t" = screenview; "&tid" = "UA-109196643-1"; "&ul" = en; "&v" = 1; "&z" = 15726875618543142345; Login = name; gaiVersion = "3.17"; }; timestamp = "2017-11-11 15:42:53 +0000"; }

So the problem is that I dont get any data in analytics, I have also setup firebase, can it be the issue, because I am getting data there.

2
I think something wrong in your code.Sagar Chauhan
You already created instance of GAI.sharedInstance() named as gai. So, use gai or GAI.sharedInstance(), why are you use both ?Sagar Chauhan
Firebase gives great analytics... Why do you need Google Analytics?Yitzchak
Thanks @Yitzchak, I completely agree with you, but the client wants google one )Narek Simonyan
Firebase is google too and can be linked to google analytics!!!Yitzchak

2 Answers

1
votes

I'm posting a new answer because it's my answer and I add more details:

You can use Firebase SDK and get analytics in your Google Analytics account. You just link them together.

Follow the instructions:

Link to instructions on Google Help

  1. Sign in to your Google Analytics account.
  2. Click Admin.
  3. In the PROPERTY column, select Create new property from the dropdown menu.
  4. Select Mobile app.
  5. Connect to Firebase. If you do not have a Firebase account, go to firebase.google.com to get started. Once you have completed the setup, return to Google Analytics and complete the above steps.
0
votes

My code still doesnt work, but I have found how to link firebase analytics to google analytics(thanks @Yitzchak). When you are adding property for mobile app you can link it to firebase, and it will automatically import data from firebase.