Tuesday, 15 September 2015

cordova - Phonegap build google analytics plugin -



cordova - Phonegap build google analytics plugin -

im testing google analytics plugin phonegap build.

i see register index page on google analytics, if seek track subpage(external page on server) page counted 5 times when load in app?

i have next code:

var gaplugin; function onbodyload() { document.addeventlistener("deviceready", ondeviceready, false); } function ondeviceready() { document.addeventlistener("resume",onresume,false); gaplugin = window.plugins.gaplugin; gaplugin.init(successhandler, errorhandler, "ua-xxxxx-1", 10); gaplugin.trackpage( successhandler, errorhandler, "index.html"); } function onresume(){ gaplugin.trackpage( successhandler, errorhandler, "index.html"); } function pagebuttonclicked() { //gaplugin.trackpage( successhandler, errorhandler, "http://www.mydomain.se/folder/news/news1.asp"); gaplugin.trackpage( nativepluginresulthandler, nativepluginerrorhandler, "http://www.mydomain.se/folder/news/news1.asp"); } function successhandler (result) { alert('successhandler - '+result); } function errorhandler (error) { alert('errorhandler - '+error); } function goingaway() { gaplugin.exit(successhandler, errorhandler); } <body onload="onbodyload();" onunload="goingaway();">

in pagebuttonclicked function, witch should use? nativepluginresulthandler calling function in phonegap.js file or? should utilize succeshandler?

is goingaway function doing anything? need it?

maybe should count index page?

does should? or go wrong?

any input appreciated, thanks.

what trying track here, looks calling trackpage on external webpage? navigating or what's going on?

anyway: far understand if reference nativepluginresulthandler have declare these functions (not 100% sure), using success function should have same result. basically:

gatrackpageview: function(page) { // phone call function hash when page changes var index = "index.html"; var trackpage = index.concat(page); console.log('tracking ' + trackpage); gaplugin.trackpage(gasuccess, gafail, trackpage); }, gasuccess: function() { // if first connection successful, track index page console.log('successfully connected google analytics'); }, gafail: function() { // generic failure function console.warn("failed connect google analytics"); },

this javascript spa phone call gatrackpageview function hash.

i did go through myself, if want can check out blog post @ http://xc.ms , contains pretty much total code how set - i'll able help out improve if share more of code though because i'm not 100% sure you're trying track :)

//p

cordova

No comments:

Post a Comment