mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(tagmanager): support to add google tagmanager id, closes #2569
This commit is contained in:
parent
7072af7c14
commit
3d37c9c9a3
@ -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"],
|
||||
|
@ -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
|
||||
|
@ -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"`
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -56,7 +56,6 @@
|
||||
require(['app'], function (app) {
|
||||
app.boot();
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
[[if .GoogleAnalyticsId]]
|
||||
@ -71,4 +70,21 @@
|
||||
</script>
|
||||
[[end]]
|
||||
|
||||
[[if .GoogleTagManagerId]]
|
||||
<script>
|
||||
dataLayer = [{
|
||||
'IsSignedIn': '[[.User.IsSignedIn]]',
|
||||
'Email': '[[.User.Email]]',
|
||||
'UserId': '[[.User.Id]]',
|
||||
'OrgId': '[[.User.OrgId]]',
|
||||
'OrgName': '[[.User.OrgName]]',
|
||||
}];
|
||||
</script>
|
||||
<!-- Google Tag Manager -->
|
||||
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-K2MJ65" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','[[.GoogleTagManagerId]]');</script>
|
||||
<!-- End Google Tag Manager -->
|
||||
[[end]]
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user