[PhoneGap Build] Plugin for Google Analytics

  • 1
  • Announcement
  • Updated 7 years ago
Adobe PhoneGap Build's Plugin for Google Analytics is now available on PhoneGap Build!

Blog post: http://build.phonegap.com/blog/analyt...

Usage instructions: https://build.phonegap.com/docs/plugins

Full JavaScript API: https://github.com/bobeast/GAPlugin/b...

More plugins in the pipe!
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
  • stoked

Posted 8 years ago

  • 1
Photo of Xxp2

Xxp2

  • 12 Posts
  • 0 Reply Likes
Is there an "officially supported" plugin list for PhoneGap?
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Here: https://build.phonegap.com/docs/plugins

But we are yet to include Google Analytics into it. We'll be doing it as soon as possible. Stay tuned!

-Amir
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
The docs for Analytics mistakenly weren't deployed. Up now.
Photo of Xxp2

Xxp2

  • 12 Posts
  • 0 Reply Likes
What about officially supported plugins for PhoneGap without Build?
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
https://github.com/phonegap/phonegap-...

I don't know if I would say its 'official' -- but that is the repository where the community has contributed numerous open-source PhoneGap plugins.
Photo of Xxp2

Xxp2

  • 12 Posts
  • 0 Reply Likes
Yeah I saw that however I noted it already had a GA (https://github.com/phonegap/phonegap-...) which differed from the one Build is supporting so wasn't sure?
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
Right -- moving forward, in general PhoneGap Build will likely integrate plugins from that repository (Google Analytics was an exception -- it was refactored but provides a similar API). We will often however need to customize things to work on our build servers.
Photo of abksharma

abksharma

  • 7 Posts
  • 0 Reply Likes
thanks mate...Are all phonegap plugin supported by cloud Build also.
now pls start working for Push notification plugin..dont wait for Christmas. our client needed it 27 Nov. He is aiming bazooka at us.
Photo of eschweiler

eschweiler

  • 4 Posts
  • 0 Reply Likes
+1 for Push Notications
Photo of Sean O'Gorman

Sean O'Gorman

  • 33 Posts
  • 0 Reply Likes
Has anyone been able successfully implement the GA plugin for build?
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Hi Sean

Try this:
https://github.com/amirudin/pgb-analytic

Remember to change GA tracking id with yours (index.html at line 24)
Photo of Cocaracha

Cocaracha

  • 11 Posts
  • 0 Reply Likes
Hello,

Please, can someone show me how we can implement the GA with PhoneGap Build and link it to my Google Analytics account?

Thank you.
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Hi Sean

Try this:
https://github.com/amirudin/pgb-analytic

Remember to change GA tracking id with yours (index.html at line 24)
Photo of AJ

AJ

  • 1 Post
  • 0 Reply Likes
I've added the PG plugin using PGB to my app. I've even tried alerting on track success and plugin init success. Nothing gets reported back to GA however.

I've even waited a day to see if it updates and nothing at all gets posted back to Google Analytics. Does anyone know how to implement the plugin succesfully? or does anyone have this confirmed as working with a PG2.0 app using PGB?
Photo of abksharma

abksharma

  • 7 Posts
  • 0 Reply Likes
I am having same issue Android
on unction goingAway() it shows JSON ERROR. while calling Button handler etc Successhandler is called always but as soon as .I exit the GA error come of JSON.
Has anyone got this working. I have alson installed Google anaytic SDK to my android enviourment.
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
I think the goingAway() issue is unrelated to whether data shows up in your GA dashboard. I would first comment that out so you are not calling unregister. Also, you should not need to install the Google analytic SDK to get this to work, unless you are trying to run it on the Android emulator.

Finally, check, double, and triple check, that you are passing the correct tracking id in your call to register which matches your dashboard account where you are trying to see the results.

If none of this gets you there, it would be helpful to see what messages are getting posted in your Eclipse or Xcode log, when run from an ide.
Photo of Yann S

Yann S

  • 214 Posts
  • 7 Reply Likes
Why Analytics is not anymore in Usage instructions: https://build.phonegap.com/docs/plugins
??

Did you stop Analytics compatibility yesterday ?
Perhaps it is a relapse with issues of server build android ?
Photo of Amir

Amir

  • 8261 Posts
  • 263 Reply Likes
Hi Yann

You do you mean with Analytics compatibility? Did you not able to use analytics on 2.0.0 and above?

-Amir
Photo of Yann S

Yann S

  • 214 Posts
  • 7 Reply Likes
new problem... this error :
cannot read property 'gaPlugin' of undefined

the code is
script src=GAPlugin.js
try{
ga=window.plugins.gaPlugin;
ga.init(fempty,fempty,"UA-XXXXXXX-1",10);
} catch (ex) { console.log(ex.message); alert(ex.message); }
Photo of Yann S

Yann S

  • 214 Posts
  • 7 Reply Likes
ok, it's working if I use the name var gaPlugin instead of ga
and if I not set a "var gaPlugin" in index.html
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
I just looked in https://build.phonegap.com/docs/plugins, and the Analytics description is still there. Browser cache issue?
Photo of Yann S

Yann S

  • 214 Posts
  • 7 Reply Likes
Is GAPplugin working on Windows Phone ?
thx in advance ;)
Photo of Bob Easterday

Bob Easterday

  • 174 Posts
  • 14 Reply Likes
Sorry. The GA plugin is currently only for Android and iOS.
Photo of Atul Chauhan

Atul Chauhan

  • 6 Posts
  • 0 Reply Likes
I am using build phonegap for a project, and am now trying to add google analytics to it.

My project has this code


function onDeviceReady() {
gaPlugin = window.plugins.gaPlugin;
gaPlugin.init(gaSuccess, gaError, "UA-XXXXXXX-X", 10);
}

which fails with an exception that says window.plugins is 'undefined'

My config.xml has


<gap:plugin name="GAPlugin" />


My index.html has


<script src="phonegap.js"></script>
<script src="GAPlugin.js"></script>


What am I doing wrong?
Photo of Yann S

Yann S

  • 214 Posts
  • 7 Reply Likes
gap:plugin name="Analytics" !!!

;)
Photo of Atul Chauhan

Atul Chauhan

  • 6 Posts
  • 0 Reply Likes


<gap:plugin name="GAPlugin" />

worked for me.

These 2 things helped me

- Rearranged references to js files
- document.addEventListener("deviceready", onDeviceReady, false); (changed to false instead of true)
Photo of martin.mcneela

martin.mcneela

  • 1 Post
  • 0 Reply Likes
I am having the same problem, I have completed all of the steps above.

Has anyone figured out how to get this working?