Skip to content

Commit e4e6f0e

Browse files
committed
Send the first page view to Google Analytics
Prior to ba311c9, we were always sending Google Analytics the page the user _last_ visited instead of the page they just navigated to. With that issue fixed, we need to send GA the initial page load as well now.
1 parent 7563419 commit e4e6f0e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

static/canjs.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ var $articleContainer,
2525
hasShownSearch;
2626

2727
(function() {
28+
29+
// Google Analytics
30+
ga('send', 'pageview', window.location.pathname);
31+
2832
//flag that determines whether or not the search has already been shown
2933
//(used for fading in or not)
3034
hasShownSearch = false;
@@ -75,7 +79,7 @@ var $articleContainer,
7579
setInterval(function() {
7680
toggleNav();
7781
}, 200);
78-
82+
7983
scrollToCurrentMenuItem();
8084
})();
8185

@@ -218,7 +222,7 @@ function navigate(href) {
218222
return xhr;
219223
},
220224
success: function(content) {
221-
225+
222226
window.history.pushState(null, null, href);
223227

224228
// Google Analytics
@@ -494,4 +498,4 @@ function buildTOC() {
494498

495499
toc += Array(level - baseLevel + 1).join('</li></ol>') + "</li></ol>";
496500
$tableOfContents.append(toc);
497-
}
501+
}

0 commit comments

Comments
 (0)