Analytics.js, phonegap doesn't call the callback function
I have followed the following tutorial :
http://www.blastam.com/blog/index.php/2013/07/ga-universal-analytics-phonegap-mobile-apps/
It's working except if the page changes just after an event (a click for
exemple)
For exemple when a user click on a button I have the following code:
_gaq.push([ '_trackPageview', 'object' ]);//work correctly on a website
using ga.js
$(location).attr('href', "index.html");
Since I'm using analytics.js in the phonegap app I have the following code
working when I replace the sleep function with an alert.
_gaq = {
'push': function (lst) {
var boolean = true;
ga('send', 'pageview', {
'page': lst[1],
'hitCallback': function () {
console.log("done");
boolean = false;
},
'hitCallbackFail': function () {
console.log("fail");
boolean = false;
}
});
function sleep() {
if (boolean === true) {
setTimeout(sleep, 50);
return;
}
}
sleep();
}
};
Any ideas?
No comments:
Post a Comment