2

I'm looking to use google analytics without a plugin with phoneGap 2.1.

I followed this thread:

How to use Google Analytics with Phonegap without a plugin?

Step:
1. download the ga.js
2. modify the ga.js file by adding one character to it. Search the ga.js file for the word "file:" and replace it with "_file:".
3. include the google analytics code in the top of your page

But it seems it doesn't work in phoneGap 2.1.

Somebody has found a solution for this problem?

Thank you


in my ga.js file I have "_file:",

in my index.html I have this code:

<script type="text/javascript" src="js/ga.js"></script> 

and in my javascript:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36500003-1']);

_gaq.push(['_setDomainName', 'none']);

_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);


_gaq.push(['_trackEvent', 'IpadVideos', 'Play', 'Gone With the Wind']);

When I'm going in the reporting of Google, in the real time I have nobody and for my event action I have checked the next day and I have nothing...

Something wrong in my code?

Community
  • 1
  • 1
user1872994
  • 71
  • 1
  • 4

1 Answers1

0

No, I have done using it and it was working for me. I was using phonegap 2.1 in iOS and android.

Please make sure that u have added edited ga.js in your index.html n set damain name to none.

_gaq.push(['_setDomainName', 'none']);

And it should work.

GA events are sometimes don't get registered immediately so wait for sometime and then check it.

Varun Agarwal
  • 299
  • 3
  • 12
  • in my ga.js file I have "_file:", in my index.html I have this code: and in my javascript: var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-36500003-1']); _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); _gaq.push(['_trackEvent', 'IpadVideos', 'Play', 'Gone With the Wind']); When I'm going in the reporting of Google, in the real time I have nobody and for my event action I have checked the next day and I have nothing... Something wrong in my code? – user1872994 Dec 05 '12 at 09:09
  • I dont find anything wrong in the code. but can u see log cats in Android their might be the issue that the domain is getting blocked. Plz see and then tell – Varun Agarwal Dec 07 '12 at 14:08
  • My application is just for IOS. In fact, I have found the problem. If I put my GA code after the cordova.js the tracking doesn't work and If my code is above it's working. It's strange because I don't have errors in the xcode console. – user1872994 Dec 10 '12 at 08:20