File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 14
14
< title > Smart WebView Offline</ title >
15
15
< link rel ="stylesheet " type ="text/css " href ="style.css ">
16
16
< script src ="script.js " type ="text/javascript "> </ script >
17
- < script defer src ="https://www.googletagmanager.com/gtag/js?id=G-7XXC1C7CRQ "> </ script >
18
- < script >
19
- window . dataLayer = window . dataLayer || [ ] ;
20
- function gtag ( ) { dataLayer . push ( arguments ) ; }
21
- gtag ( 'js' , new Date ( ) ) ;
22
- gtag ( 'config' , 'G-7XXC1C7CRQ' ) ;
23
- </ script >
24
17
</ head >
25
18
< body >
26
19
< img src ="front_splash.png " class ="head-logo " />
Original file line number Diff line number Diff line change @@ -105,3 +105,26 @@ function get_location() {
105
105
function print_page ( ) {
106
106
window . print ( ) ;
107
107
}
108
+
109
+ // Function to load gtag.js (Google Analytics)
110
+ function load_gtag ( ) {
111
+ // Create the script tag
112
+ var script = document . createElement ( 'script' ) ;
113
+ script . async = true ;
114
+ script . src = 'https://www.googletagmanager.com/gtag/js?id=G-7XXC1C7CRQ' ; // Replace with your actual GA ID
115
+
116
+ // Get the first script tag on the page
117
+ var firstScript = document . getElementsByTagName ( 'script' ) [ 0 ] ;
118
+
119
+ // Insert the script before the first script
120
+ firstScript . parentNode . insertBefore ( script , firstScript ) ;
121
+
122
+ // Initialize the dataLayer and configure gtag.js
123
+ window . dataLayer = window . dataLayer || [ ] ;
124
+ function gtag ( ) { dataLayer . push ( arguments ) ; }
125
+ gtag ( 'js' , new Date ( ) ) ;
126
+ gtag ( 'config' , 'G-7XXC1C7CRQ' ) ; // Replace with your actual GA ID
127
+ }
128
+
129
+ // Add an event listener to call loadGtag() after the page has finished loading
130
+ window . addEventListener ( 'load' , load_gtag ) ;
You can’t perform that action at this time.
0 commit comments