PhoneGap App not working with Google Analytics
After Two days, Found solution from the Google Group Phonegap page , This answer worked for me. thanks Mayor, his answer is
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','gaU');
gaU('create','UA-XXXXXXXX-X',{'storage':'none','clientId':device.uuid});
gaU('set','checkProtocolTask',null);
gaU('set','anonymizeIp',true);
gaU('set','forceSSL',true);
gaU('send','pageview',{'title':'I heart Cordova','page':'/cordova'});
gaU('send','event',{'eventCategory':'My_Category','eventAction':'My_Action','eventLabel':'Event_Label','eventValue':11});
notes:
you must set the url for google-analytics.com to use http or https (the default has // which tries to load file:// which does not work)
use must turn off 'storage' and add a clientId which you can use the Cordova device.uuid
you must disable protocol checking (because file:// does not work) by setting checkProtocolTask to null
this only works with the new "Universal" analytics. your GA account must be created as "Website" rather than "Mobile App"