File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ var constants = {
1414 _authorURL : 'Author Email or Website' ,
1515 _codeCredit : 'Author Code Credit' ,
1616 _githubRepo : 'Author Code Repo' ,
17+ _googleAnalytics : 'Google Analytics Tracking ID' ,
1718 // Map Settings
1819 _tileProvider : 'Basemap Tiles' ,
1920 _markercluster : 'Cluster Markers' ,
Original file line number Diff line number Diff line change @@ -738,6 +738,20 @@ $(window).on('load', function() {
738738 setTimeout ( showMap , 50 ) ;
739739 }
740740 }
741+
742+ // Add Google Analytics if the ID exists
743+ var ga = getSetting ( '_googleAnalytics' ) ;
744+ console . log ( ga )
745+ if ( ga && ga . length >= 10 ) {
746+ var gaScript = document . createElement ( 'script' ) ;
747+ gaScript . setAttribute ( 'src' , 'https://www.googletagmanager.com/gtag/js?id=' + ga ) ;
748+ document . head . appendChild ( gaScript ) ;
749+
750+ window . dataLayer = window . dataLayer || [ ] ;
751+ function gtag ( ) { dataLayer . push ( arguments ) ; }
752+ gtag ( 'js' , new Date ( ) ) ;
753+ gtag ( 'config' , ga ) ;
754+ }
741755 }
742756
743757 /**
You can’t perform that action at this time.
0 commit comments