Only send Google Analytics data if analytics was loaded successfully
Prevent errors in local environment and if people are using blockers.
This commit is contained in:
parent
60e1a9d8b3
commit
3bc4631924
1 changed files with 8 additions and 4 deletions
|
|
@ -52,8 +52,10 @@ $.when($.ready).then(function() {
|
|||
}, '', href)
|
||||
|
||||
// Track on Google Analytics
|
||||
ga('set', 'page', href)
|
||||
ga('send', 'pageview')
|
||||
if (typeof(ga) === 'function') {
|
||||
ga('set', 'page', href)
|
||||
ga('send', 'pageview')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -66,8 +68,10 @@ $.when($.ready).then(function() {
|
|||
$('#content').html(e.state.content)
|
||||
|
||||
// Track on Google Analytics
|
||||
ga('set', 'page', e.state.href)
|
||||
ga('send', 'pageview')
|
||||
if (typeof(ga) === 'function') {
|
||||
ga('set', 'page', e.state.href)
|
||||
ga('send', 'pageview')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue