Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3d37c9c9
Commit
3d37c9c9
authored
Aug 21, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(tagmanager): support to add google tagmanager id, closes #2569
parent
7072af7c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
2 deletions
+29
-2
.bra.toml
+1
-1
conf/defaults.ini
+3
-0
pkg/api/dtos/models.go
+1
-0
pkg/api/index.go
+5
-0
pkg/setting/setting.go
+2
-0
public/views/index.html
+17
-1
No files found.
.bra.toml
View file @
3d37c9c9
...
...
@@ -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"
],
...
...
conf/defaults.ini
View file @
3d37c9c9
...
...
@@ -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
...
...
pkg/api/dtos/models.go
View file @
3d37c9c9
...
...
@@ -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"`
...
...
pkg/api/index.go
View file @
3d37c9c9
...
...
@@ -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
}
...
...
pkg/setting/setting.go
View file @
3d37c9c9
...
...
@@ -116,6 +116,7 @@ var (
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
)
...
...
public/views/index.html
View file @
3d37c9c9
...
...
@@ -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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment