Skip to content

Commit 82eaa02

Browse files
committed
Attempt to get Google Analytics working for pushstate
1 parent 4a806dc commit 82eaa02

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/source/_assets/js/nav.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,15 @@ $.when($.ready).then(function() {
3838

3939
// Add page load to brower history
4040
window.history.pushState({
41+
'href': href,
4142
'title': title,
4243
'nav': $(html).find('#nav').html(),
4344
'content': $(html).find('#content').html()
4445
}, '', href)
46+
47+
// Track on Google Analytics
48+
ga('set', 'page', href)
49+
ga('send', 'pageview')
4550
})
4651
})
4752

@@ -53,6 +58,10 @@ $.when($.ready).then(function() {
5358
$('title').text(e.state.title)
5459
$('#nav').html(e.state.nav)
5560
$('#content').html(e.state.content)
61+
62+
// Track on Google Analytics
63+
ga('set', 'page', e.state.href)
64+
ga('send', 'pageview')
5665
}
5766
}
5867

0 commit comments

Comments
 (0)