Skip to content

Commit

Permalink
add googleAnalytics support
Browse files Browse the repository at this point in the history
  • Loading branch information
dularion committed Feb 4, 2019
1 parent 9c8bdea commit bae2ee8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
19 changes: 19 additions & 0 deletions grails-app/taglib/streama/AssetSettingTagLib.groovy
Expand Up @@ -40,4 +40,23 @@ class AssetSettingTagLib {
out << getAssetFromSetting(setting)
out << ');}</style>'
}


def googleAnalytics = { attribs ->
def enabled = grailsApplication.config.streama.googleAnalytics?.enabled
def id = grailsApplication.config.streama.googleAnalytics?.id

if(!enabled){
return
}

out << '<!-- Global site tag (gtag.js) - Google Analytics -->'
out << '<script async src="https://www.googletagmanager.com/gtag/js?id='+ id +'"></script>'
out << '<script>'
out << 'window.dataLayer = window.dataLayer || [];'
out << 'function gtag(){dataLayer.push(arguments);}'
out << 'gtag(\'js\', new Date());'
out << 'gtag(\'config\', \'UA-124224387-2\');'
out << '</script>'
}
}
2 changes: 2 additions & 0 deletions grails-app/views/index.gsp
Expand Up @@ -42,5 +42,7 @@

<asset:javascript src="vendor.js" />
<asset:javascript src="streama/streama.js" />

<g:googleAnalytics/>
</body>
</html>
3 changes: 3 additions & 0 deletions grails-app/views/login/auth.gsp
Expand Up @@ -85,5 +85,8 @@
// -->
</script>


<g:googleAnalytics/>

</body>
</html>

0 comments on commit bae2ee8

Please sign in to comment.