Phonegap And Google Analytics Are Not Working
I'm building an app with phonegap and wanted to use Google Analytics. I installed this plugin with the CLI and implemented the following lines of code into my deviceReady event: an
Solution 1:
No need to use plugin. You can directly call the google analytics API by using measurement protocol tracking id. It works fine in Andriod, IOS, Windows and Blackberry.
var dataform = {};
dataform.v = 1;
dataform.tid = "UA-xxxxxxxx-2";
dataform.cid = "device id";
dataform.t = "appview";
dataform.an = "name";
dataform.av = "0.0.1";
dataform.cd = "Home Screen";
var url = "http://www.google-analytics.com/collect";
$.ajax(url, {
type: "post",
contentType: "text/plain",
data: dataform
})
.done(function(result) {
alert("success");
})
.fail(function(error) {
alert("fail");
});
Post a Comment for "Phonegap And Google Analytics Are Not Working"