Add Google Analytics config option
This commit is contained in:
parent
1ff523881d
commit
fa737a887b
|
@ -88,6 +88,9 @@ var (
|
||||||
AppDataPath string
|
AppDataPath string
|
||||||
AppWorkPath string
|
AppWorkPath string
|
||||||
|
|
||||||
|
// User settings
|
||||||
|
GoogleAnalyticsID string
|
||||||
|
|
||||||
// Server settings
|
// Server settings
|
||||||
Protocol Scheme
|
Protocol Scheme
|
||||||
Domain string
|
Domain string
|
||||||
|
@ -695,6 +698,7 @@ func NewContext() {
|
||||||
|
|
||||||
sec := Cfg.Section("server")
|
sec := Cfg.Section("server")
|
||||||
AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
|
AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
|
||||||
|
GoogleAnalyticsID = Cfg.Section("").Key("GOOGLE_ANALYTICS_ID").String()
|
||||||
|
|
||||||
Protocol = HTTP
|
Protocol = HTTP
|
||||||
if sec.Key("PROTOCOL").String() == "https" {
|
if sec.Key("PROTOCOL").String() == "https" {
|
||||||
|
|
|
@ -60,6 +60,9 @@ func NewFuncMap() []template.FuncMap {
|
||||||
"DisableGravatar": func() bool {
|
"DisableGravatar": func() bool {
|
||||||
return setting.DisableGravatar
|
return setting.DisableGravatar
|
||||||
},
|
},
|
||||||
|
"GoogleAnalyticsID": func() string {
|
||||||
|
return setting.GoogleAnalyticsID
|
||||||
|
},
|
||||||
"ShowFooterTemplateLoadTime": func() bool {
|
"ShowFooterTemplateLoadTime": func() bool {
|
||||||
return setting.ShowFooterTemplateLoadTime
|
return setting.ShowFooterTemplateLoadTime
|
||||||
},
|
},
|
||||||
|
|
|
@ -105,6 +105,17 @@
|
||||||
|
|
||||||
<script src="{{AppSubUrl}}/vendor/plugins/cssrelpreload/loadCSS.min.js"></script>
|
<script src="{{AppSubUrl}}/vendor/plugins/cssrelpreload/loadCSS.min.js"></script>
|
||||||
<script src="{{AppSubUrl}}/vendor/plugins/cssrelpreload/cssrelpreload.min.js"></script>
|
<script src="{{AppSubUrl}}/vendor/plugins/cssrelpreload/cssrelpreload.min.js"></script>
|
||||||
|
{{if .GoogleAnalyticsID}}
|
||||||
|
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{.GoogleAnalyticsID}}"></script>
|
||||||
|
<script>
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
|
||||||
|
gtag('config', '{{GoogleAnalyticsID}}');
|
||||||
|
</script>
|
||||||
|
{{end}}
|
||||||
{{if .PageIsUserProfile}}
|
{{if .PageIsUserProfile}}
|
||||||
<meta property="og:title" content="{{.Owner.Name}}" />
|
<meta property="og:title" content="{{.Owner.Name}}" />
|
||||||
<meta property="og:type" content="profile" />
|
<meta property="og:type" content="profile" />
|
||||||
|
|
Loading…
Reference in New Issue