Skip to content

Commit d2b391c

Browse files
committed
web app script update
1 parent 2c1cf4d commit d2b391c

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

docs/index.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414
<title>Smart WebView Offline</title>
1515
<link rel="stylesheet" type="text/css" href="style.css">
1616
<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>
2417
</head>
2518
<body>
2619
<img src="front_splash.png" class="head-logo" />

docs/script.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,26 @@ function get_location() {
105105
function print_page(){
106106
window.print();
107107
}
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);

0 commit comments

Comments
 (0)