diff options
Diffstat (limited to 'tpl/tplimpl/embedded/templates/google_analytics_async.html')
-rwxr-xr-x | tpl/tplimpl/embedded/templates/google_analytics_async.html | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tpl/tplimpl/embedded/templates/google_analytics_async.html b/tpl/tplimpl/embedded/templates/google_analytics_async.html index 18e18a168..8fb746e0b 100755 --- a/tpl/tplimpl/embedded/templates/google_analytics_async.html +++ b/tpl/tplimpl/embedded/templates/google_analytics_async.html @@ -5,7 +5,20 @@ {{ template "__ga_js_set_doNotTrack" $ }} if (!doNotTrack) { window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; + {{- if $pc.UseSessionStorage }} + if (window.sessionStorage) { + var GA_SESSION_STORAGE_KEY = 'ga:clientId'; + ga('create', '{{ . }}', { + 'storage': 'none', + 'clientId': sessionStorage.getItem(GA_SESSION_STORAGE_KEY) + }); + ga(function(tracker) { + sessionStorage.setItem(GA_SESSION_STORAGE_KEY, tracker.get('clientId')); + }); + } + {{ else }} ga('create', '{{ . }}', 'auto'); + {{ end -}} ga('send', 'pageview'); {{ if $pc.AnonymizeIP }}ga('set', 'anonymizeIp', true);{{ end -}} } |