PDA

View Full Version : Google Analytics code in Mobile template


suko22
04-30-2015, 06:46 AM
Hi, I have a vbulletin 3.8 forum with a Mobile Style for users with Android, Iphone, Ipad or WP. I have this Google Analytics code for both styles (desktop and pc), at the end of 'headinclude':
<script>
(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','//www.google-analytics.com/analytics.js','ga');


ga('create', 'UA-XXXXXXX', 'auto');
ga('send', 'pageview');


</script>


Code works perfect in Desktop version, but not in mobile version. In Google Analytics, if I filter visitors by movile devices, nothing appears.


When I review the code in Mobile Style (with chrome) I can see the Google Analytics code, but for any reason it doesn?t work.


Any idea or solution???

RichieBoy67
04-30-2015, 07:01 AM
I do not believe Google filters have anything to do with what theme is being used.

suko22
04-30-2015, 07:20 AM
I do not believe Google filters have anything to do with what theme is being used.
Then explain this. Yesterday I shared a link in Facebook to my forum, after 24 hours facebook stats say that this link had +40.000 clicks. But Google Analytics says it had only 2.900 visitors from Desktop and 140 visitors from Mobile.

My site (forum is just a small part of it) has 70% traffic from mobile devices, 6% tablets and 24% from desktop. So that amount of visitors from desktop (2.900) is normal, but 140 from mobile when Facebook says +40.000 cliks?? I?m sure Google Analitcs code is not working fine in Mobile Style.

RichieBoy67
04-30-2015, 07:38 AM
Then explain this. Yesterday I shared a link in Facebook to my forum, after 24 hours facebook stats say that this link had +40.000 clicks. But Google Analytics says it had only 2.900 visitors from Desktop and 140 visitors from Mobile.

My site (forum is just a small part of it) has 70% traffic from mobile devices, 6% tablets and 24% from desktop. So that amount of visitors from desktop (2.900) is normal, but 140 from mobile when Facebook says +40.000 cliks?? I?m sure Google Analitcs code is not working fine in Mobile Style.

#1 - Is that the newest code or the older one?

#2 - When did you add that code?

#3 - try adding the code to the footer as well in the mobile theme.

suko22
04-30-2015, 07:44 AM
#1 - Is that the newest code or the older one?

#2 - When did you add that code?

#3 - try adding the code to the footer as well in the mobile theme.
That code is the actual code you can find in G.Analytics settings. I put this code in forum several months ago.
I?ll take your advice and will place code in footer, and will try with this alternative code I found in other website:

<script type="text/javascript">


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


(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')

[


0]; s.parentNode.insertBefore(ga, s);
})();


</script>