Update Google analytics token handling.

This commit is contained in:
David Russell 2017-10-24 15:10:28 +07:00
parent 2618a6e7d5
commit c686ced77f
2 changed files with 8 additions and 3 deletions

View File

@ -1,11 +1,16 @@
@(gaToken: String)
@(gaToken: String, gpu: Boolean)
@if(gaToken != null) {
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
@if(gpu) {
ga('create', '@gaToken', 'auto', 'gpu');
ga('gpu.send', 'pageview');
} else {
ga('create', '@gaToken', 'auto');
ga('send', 'pageview');
}
</script>
}

View File

@ -2,10 +2,10 @@
@if(!offline) {
@if(!serverPrinting) {
@if(gpToken) {
@GoogleAnalytics(gpToken)
@GoogleAnalytics(gpToken, false)
}
@if(ssm.hasGAToken()) {
@GoogleAnalytics(ssm.fetchGAToken())
@GoogleAnalytics(ssm.fetchGAToken(), true)
}
}
}