Skip to content

Commit

Permalink
web app script update
Browse files Browse the repository at this point in the history
  • Loading branch information
mgks committed Dec 27, 2024
1 parent 2c1cf4d commit d2b391c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
7 changes: 0 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@
<title>Smart WebView Offline</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js" type="text/javascript"></script>
<script defer src="https://www.googletagmanager.com/gtag/js?id=G-7XXC1C7CRQ"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-7XXC1C7CRQ');
</script>
</head>
<body>
<img src="front_splash.png" class="head-logo" />
Expand Down
23 changes: 23 additions & 0 deletions docs/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,26 @@ function get_location() {
function print_page(){
window.print();
}

// Function to load gtag.js (Google Analytics)
function load_gtag() {
// Create the script tag
var script = document.createElement('script');
script.async = true;
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-7XXC1C7CRQ'; // Replace with your actual GA ID

// Get the first script tag on the page
var firstScript = document.getElementsByTagName('script')[0];

// Insert the script before the first script
firstScript.parentNode.insertBefore(script, firstScript);

// Initialize the dataLayer and configure gtag.js
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-7XXC1C7CRQ'); // Replace with your actual GA ID
}

// Add an event listener to call loadGtag() after the page has finished loading
window.addEventListener('load', load_gtag);

0 comments on commit d2b391c

Please sign in to comment.