Skip to content

Commit

Permalink
[FEATURE] Google Tag Manager (#312)
Browse files Browse the repository at this point in the history
* [FEATURE] Google Tag Manager

* [TASK] remove condition with regexp and use .if to improve performance
  • Loading branch information
pixelmatseriks authored and MattiasNilsson committed Oct 31, 2017
1 parent 1513a8d commit 17859dc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Configuration/TypoScript/Library/page.gtm.setupts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Google Analytics track pageview and add script for event tracking
page.headerData.17895 = TEXT
page.headerData.17895 {
if.isTrue = {$themes.configuration.tracking.ga_gtmid}
value (

<!-- Google Tag Manager -->
<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='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','{$themes.configuration.tracking.ga_gtmid}');
</script>
<!-- End Google Tag Manager -->
)
}

page.3 = TEXT
page.3 {
if.isTrue = {$themes.configuration.tracking.ga_gtmid}
value (

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={$themes.configuration.tracking.ga_gtmid}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ themes.configuration.tracking.ga_account =
# customsubcategory=googleWebMasterTools= Google Webmaster Tools
# cat=theme,expert/googleWebMasterTools/; type=string; label= Google Search Console
themes.configuration.tracking.ga_siteVerification =


#############################################
# Google Tag Manager
#############################################
# customsubcategory=googleWebMasterTools= Google Webmaster Tools
# cat=theme,expert/googleWebMasterTools/; type=string; label= Google Tag Manager Id
themes.configuration.tracking.ga_gtmid =

0 comments on commit 17859dc

Please sign in to comment.