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) { @if(gaToken != null) {
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (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), (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) 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'); })(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('create', '@gaToken', 'auto');
ga('send', 'pageview'); ga('send', 'pageview');
}
</script> </script>
} }

View File

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