diff --git a/.bra.toml b/.bra.toml index a3ca1d7af8f..ef1a925158d 100644 --- a/.bra.toml +++ b/.bra.toml @@ -9,7 +9,7 @@ watch_dirs = [ "$WORKDIR/public/views", "$WORKDIR/conf", ] -watch_exts = [".go", ".ini", ".toml"] +watch_exts = [".go", ".ini", ".toml", ".html"] build_delay = 1500 cmds = [ ["go", "build", "-o", "./bin/grafana-server"], diff --git a/conf/defaults.ini b/conf/defaults.ini index 7ca5191c4e7..8eafec90e0d 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -98,6 +98,9 @@ reporting_enabled = true # Google Analytics universal tracking code, only enabled if you specify an id here google_analytics_ua_id = +# Google Tag Manager ID, only enabled if you specify an id here +google_tag_manager_id = + #################################### Security #################################### [security] # default admin user, created on startup diff --git a/pkg/api/dtos/models.go b/pkg/api/dtos/models.go index 3e1826f56fb..9a4400adbdf 100644 --- a/pkg/api/dtos/models.go +++ b/pkg/api/dtos/models.go @@ -17,6 +17,7 @@ type LoginCommand struct { type CurrentUser struct { IsSignedIn bool `json:"isSignedIn"` + Id int64 `json:"id"` Login string `json:"login"` Email string `json:"email"` Name string `json:"name"` diff --git a/pkg/api/index.go b/pkg/api/index.go index 8f486c4b785..556db006b2f 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -13,6 +13,7 @@ func setIndexViewData(c *middleware.Context) error { } currentUser := &dtos.CurrentUser{ + Id: c.UserId, IsSignedIn: c.IsSignedIn, Login: c.Login, Email: c.Email, @@ -47,6 +48,10 @@ func setIndexViewData(c *middleware.Context) error { c.Data["GoogleAnalyticsId"] = setting.GoogleAnalyticsId } + if setting.GoogleTagManagerId != "" { + c.Data["GoogleTagManagerId"] = setting.GoogleTagManagerId + } + return nil } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 3ac4b16db64..43bc8f6247d 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -114,8 +114,9 @@ var ( appliedCommandLineProperties []string appliedEnvOverrides []string - ReportingEnabled bool - GoogleAnalyticsId string + ReportingEnabled bool + GoogleAnalyticsId string + GoogleTagManagerId string // LDAP LdapEnabled bool @@ -415,6 +416,7 @@ func NewConfigContext(args *CommandLineArgs) { analytics := Cfg.Section("analytics") ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true) GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String() + GoogleTagManagerId = analytics.Key("google_tag_manager_id").String() ldapSec := Cfg.Section("auth.ldap") LdapEnabled = ldapSec.Key("enabled").MustBool(false) diff --git a/public/views/index.html b/public/views/index.html index 47f00728eb7..319c5cfe1f3 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -56,7 +56,6 @@ require(['app'], function (app) { app.boot(); }) - [[if .GoogleAnalyticsId]] @@ -71,4 +70,21 @@ [[end]] + [[if .GoogleTagManagerId]] + + + + + + [[end]]