0

I'm using this tutorial for implementing the Google Analytics plugin in my PhoneGap 2.8.1 project. After following all steps, the build successfuly and the code is running, and I even see in the console that the Analytics site is returning 200 HTTP status code (ok). But I'm still seeing no hits in Google Analytics website itself. Can anyone help in figuring out the problem?

mram888
  • 4,449
  • 5
  • 30
  • 58
Efi Debi
  • 61
  • 2
  • 12

1 Answers1

1

Take a look at PG google analytic plugin and instruction directly from them: https://github.com/phonegap-build/GAPlugin

Remember: To use mobile Google Analytic, you have to create a mobile application tracking on your GA account for this to work.

Otherwise, see this alternative solution for not using plugin: How to use Google Analytics with Phonegap without a plugin?

========= Requirement for V2 GA plugin

Since you are not on PG 3, you do not need plugman. You have to include the plugin manually.

Your app must link the following frameworks:

CoreData.framework
SystemConfiguration.framework
libz.dylib
libGoogleAnalytics.a

Include the following file:

GAI.h
GAITrackedViewController.h
GAITracker.h
GAITransaction.h
GAITransactionItem.h
libGoogleAnalytics.a

You can find these files here: https://github.com/phonegap-build/GAPlugin/tree/master/src/ios

May also need other linker flag: remove "-all_load" and add "-ObjC"

Then include the plugin:

GAPlugin.h
GAPlugin.m

Add this to your config.xml:

<feature name="GAPlugin">
    <param name="ios-package" value="GAPlugin"/>
</feature>

And include and call the javascript in your html5 code after deviceready event.

Community
  • 1
  • 1
Noogen
  • 1,482
  • 11
  • 12
  • This plugin is different form what I'm using, but the usage is almost the same. Did you have success with it? I'm using 2 seconds as the time period, is it too short? I created "mobile app" (not site) profile in my GA account, but there are no results just yet. – Efi Debi Aug 19 '13 at 18:27
  • It might be too short there. I currently have it at 10 seconds. "For each tracker instance on a device, each app instance starts with 60 hits that are replenished at a rate of 1 hit every 2 seconds. Applies to All hits." https://developers.google.com/analytics/devguides/collection/gajs/limits-quotas – Noogen Aug 19 '13 at 19:31
  • Yes, it is working. Plus tracking are queued up locally and sent/request in bulk so you don't need to set it at 2 seconds, which is too low of a freq. – Noogen Aug 19 '13 at 19:55
  • I changed it to be 10 sec, no success in seeing data in GA. I think I have to give the plugin you suggested a try (eventhough I don't like to change what I already did). Will update. – Efi Debi Aug 20 '13 at 07:14
  • Hi Noogen, this might be a dumb question - but how exactly can I install plugman on my Mac (in order to install this plugin you recommended)? – Efi Debi Aug 22 '13 at 16:49
  • Google updated GA SDK to 3.0 so I've rewritten the instruction above. Please also see the plugin for the SDK 2.0 source: https://github.com/phonegap-build/GAPlugin/tree/master/src/ios – Noogen Aug 22 '13 at 17:48
  • By the time you answer, would like to let all of you how are facing the same issue that I managed to implement GA without plugin. See [this github project](https://github.com/ggendre/GALocalStorage). SQuick and simple, and works perfectly. – Efi Debi Aug 22 '13 at 17:57
  • Efi, didn't I gave you the alternative link in my original answer too? It link to a stackoverflow question which has the github link you posted. – Noogen Aug 22 '13 at 18:00
  • Just note that native SDK gives you a lot more than just page tracking such as what device is being used, screen size, etc... – Noogen Aug 22 '13 at 18:04
  • Correct Noogen, that's why I marked your answer as the accepted answer, hope it's ok (I wanted to make the life easier for others). It is a pity that I couldn't get the plugman on my Mac, but collecting page views is doing the work for me for now. If you could explain how to use plugman and install the plugin, that would be great! – Efi Debi Aug 23 '13 at 09:47
  • Which kind of view should be created for the analytics property? Is it All MobileApp data or All website data? Am using phonegap in ios and andorid application. – Linson Dec 20 '13 at 05:50