Page 1 of 1

google analytics code not appearing in view source

Posted: Mon Mar 18, 2013 7:47 pm
by anilsojitra

I've added the following code as Custom Javascript in the Load event.

var _gaq = _gaq || [];
gaq.push(['setAccount', 'UA-17912306-1']);
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);
})();

When I view the mobile site (http://proofing.thebigsheep.co.uk/mob...) in a desktop browser and view the source code I cannot see the code above.

Please can you help me identify why the GA tracking code is not being exported from the project.


google analytics code not appearing in view source

Posted: Mon Mar 18, 2013 7:53 pm
by Maryna Brodina

Hello! Could you make your app link public and post the link here (go to Test, check Public)


google analytics code not appearing in view source

Posted: Tue Mar 19, 2013 9:49 am
by anilsojitra

google analytics code not appearing in view source

Posted: Tue Mar 19, 2013 9:54 am
by Kateryna Grynko

Hello,
We'll test.


google analytics code not appearing in view source

Posted: Tue Mar 19, 2013 10:05 am
by anilsojitra

Thank you, I appreciate your help.


google analytics code not appearing in view source

Posted: Tue Mar 19, 2013 10:09 am
by Kateryna Grynko

The code that you entered in editor is successfully added to http://proofing.thebigsheep.co.uk/mob... as a part of JavaScript function "screen_AC16_onLoad".


google analytics code not appearing in view source

Posted: Tue Mar 19, 2013 10:18 am
by anilsojitra

Excellent. So please can you confirm that the GA tracking is successfully implemented in the mobile web app and GA will track page views.


google analytics code not appearing in view source

Posted: Tue Mar 19, 2013 11:02 am
by Kateryna Grynko

You can't add Google Analytics this way, because JavaScript should run before page load.
You can add Panel component to page and place there the following code:

code<script>
var _gaq = _gaq || [];
gaq&#46;push(['setAccount', 'UA-17912306-1']);
gaq&#46;push(['trackPageview']);

(function() {
var ga = document&#46;createElement('script'); ga&#46;type = 'text&#47;javascript'; ga&#46;async = true;
ga&#46;src = ('https:' == document&#46;location&#46;protocol ? 'https:&#47;&#47;ssl' : 'http:&#47;&#47;www') + '&#46;google-analytics&#46;com&#47;ga&#46;js';
var s = document&#46;getElementsByTagName('script')[0]; s&#46;parentNode&#46;insertBefore(ga, s);
})();
<&#47;script>/code