1
0
Fork 0
mirror of https://github.com/dillonzq/LoveIt.git synced 2025-04-17 19:11:57 +02:00

feat(analytics): update Google analytics.js to gtag.js ()

This commit is contained in:
Dillon 2020-05-12 20:51:07 +08:00 committed by GitHub
parent 2ab3d976c0
commit 83869e0fc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 16 deletions

View file

@ -975,9 +975,6 @@ enableEmoji = true
# whether to anonymize IP
# 是否匿名化用户 IP
anonymizeIP = true
# whether to use cookie
# 是否使用 cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""

View file

@ -596,8 +596,6 @@ Please open the code block below to view the complete sample configuration :(far
id = ""
# whether to anonymize IP
anonymizeIP = true
# whether to use cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""

View file

@ -601,8 +601,6 @@ Please open the code block below to view the complete sample configuration :(far
id = ""
# whether to anonymize IP
anonymizeIP = true
# whether to use cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""

View file

@ -599,8 +599,6 @@ hugo
id = ""
# 是否匿名化用户 IP
anonymizeIP = true
# 是否使用 cookie
cookie = false
# Fathom Analytics
[params.analytics.fathom]
id = ""

View file

@ -1,3 +1,4 @@
{{- .Scratch.Set "version" "0.2.7" -}}
{{- $version := "0.2.X" -}}
{{- /* LoveIt theme version detection */ -}}
@ -10,7 +11,6 @@
{{- end -}}
{{- $params := .Params | merge .Site.Params.page -}}
{{- .Scratch.Set "version" "0.2.6" -}}
{{- if eq hugo.Environment "production" -}}
{{- .Scratch.Set "cdn" .Site.Params.cdn -}}

View file

@ -2,18 +2,16 @@
{{- /* Google Analytics */ -}}
{{- with .google.id -}}
<script type="text/javascript">
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', '{{ . }}', {{- if $.google.cookie }}'auto'{{ else }}{ 'storage': 'none' }{{ end }});
{{- if $.google.anonymizeIP }}ga('set', 'anonymizeIp', true);{{ end -}}
ga('send', 'pageview');
window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());
gtag('config', '{{ . }}'{{ if $.google.anonymizeIP }}, { 'anonymize_ip': true }{{ end }});
</script>
{{- dict "source" "https://www.google-analytics.com/analytics.js" "async" true | partial "plugin/script.html" -}}
{{- printf "https://www.googletagmanager.com/gtag/js?id=%s" . | dict "async" true "source" | partial "plugin/script.html" -}}
{{- end -}}
{{- /* Fathom Analytics */ -}}
{{- with .fathom.id -}}
<script type="text/javascript">
window.fathom=window.fathom||function(){(fathom.q=fathom.q||[]).push(arguments)};
window.fathom=window.fathom||function(){(fathom.q=fathom.q||[]).push(arguments);};
fathom('set', 'siteId', '{{ . }}');
fathom('trackPageview');
</script>