From d2b391c986bebd08f4b8a26e487dabd761796003 Mon Sep 17 00:00:00 2001 From: mgks Date: Sat, 28 Dec 2024 01:32:18 +0530 Subject: [PATCH] web app script update --- docs/index.html | 7 ------- docs/script.js | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/docs/index.html b/docs/index.html index 7189f75..a341aed 100644 --- a/docs/index.html +++ b/docs/index.html @@ -14,13 +14,6 @@ Smart WebView Offline - - diff --git a/docs/script.js b/docs/script.js index faeac71..591c7f8 100644 --- a/docs/script.js +++ b/docs/script.js @@ -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);