Skip to content

Commit a7d2781

Browse files
committed
Move Google Analytics to the <head>
Related to donejs/developer-relations#52 (comment)
1 parent 73841e6 commit a7d2781

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

_layouts/default.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
<link rel="stylesheet" type="text/css" href="stylesheets/tango.css">
1010
<link href='/favicon.ico' rel='shortcut icon' type='image/x-icon' />
1111
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
12+
<script>
13+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
14+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
15+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
16+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
17+
ga('create', 'UA-2302003-13', 'auto');
18+
ga('send', 'pageview');
19+
</script>
1220
</head>
1321
<body>
1422
<div id='bg'>

javascripts/application.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ can.Control('Menu', {
110110
this._markActiveAnalytics = setTimeout(function(){
111111
var path = current.parents('li').find('>a').slice(0,-1).map(function(){ return $(this).text() });
112112
path = $.makeArray(path).reverse().join('> ').replace(/\s+$/, "");
113-
_gaq.push(['_trackEvent', 'sectionRead', path]);
113+
ga('send', {
114+
eventAction: path,
115+
eventCategory: 'sectionRead',
116+
hitType: 'event'
117+
});
114118
}, 5000)
115119
var currentLevel = current.data('level'),
116120
activeLevel = active.data('level'),
@@ -358,14 +362,3 @@ if(isMobile){
358362
$('#content-wrapper').prepend(header)
359363
}
360364
$('a[href$=#dom_helpers], a[href$=#events]').prepend('<span class="special">&#x2605;</span>');
361-
362-
// google analytics
363-
var _gaq = _gaq || [];
364-
_gaq.push(['_setAccount', 'UA-2302003-13']);
365-
_gaq.push(['_trackPageview']);
366-
367-
(function() {
368-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
369-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
370-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
371-
})();

0 commit comments

Comments
 (0)