ga4 to separate js file
This commit is contained in:
parent
e0ee42e61e
commit
a9c0ef318c
28
index.html
28
index.html
@ -10,33 +10,7 @@
|
|||||||
<link rel="stylesheet" href="css/popup.css">
|
<link rel="stylesheet" href="css/popup.css">
|
||||||
<link rel="stylesheet" href="css/searchbar.css">
|
<link rel="stylesheet" href="css/searchbar.css">
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<!-- Google tag (gtag.js) Github Pages -->
|
<script src="./js/ga4.js"></script>
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-C44R8LD9MC"></script>
|
|
||||||
<script>
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
|
||||||
function gtag(){dataLayer.push(arguments);}
|
|
||||||
gtag('js', new Date());
|
|
||||||
|
|
||||||
gtag('config', 'G-C44R8LD9MC');
|
|
||||||
</script>
|
|
||||||
<!-- Google tag (gtag.js) Netlify -->
|
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-0R2ZXFSYVT"></script>
|
|
||||||
<script>
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
|
||||||
function gtag(){dataLayer.push(arguments);}
|
|
||||||
gtag('js', new Date());
|
|
||||||
|
|
||||||
gtag('config', 'G-0R2ZXFSYVT');
|
|
||||||
</script>
|
|
||||||
<!-- Google tag (gtag.js) Render -->
|
|
||||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MND1TVBSXV"></script>
|
|
||||||
<script>
|
|
||||||
window.dataLayer = window.dataLayer || [];
|
|
||||||
function gtag(){dataLayer.push(arguments);}
|
|
||||||
gtag('js', new Date());
|
|
||||||
|
|
||||||
gtag('config', 'G-MND1TVBSXV');
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
49
js/ga4.js
Normal file
49
js/ga4.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
function addGoogleAnalyticsTags() {
|
||||||
|
// GitHub Pages
|
||||||
|
var githubAnalyticsScript = document.createElement('script');
|
||||||
|
githubAnalyticsScript.async = true;
|
||||||
|
githubAnalyticsScript.src = 'https://www.googletagmanager.com/gtag/js?id=G-C44R8LD9MC';
|
||||||
|
document.head.appendChild(githubAnalyticsScript);
|
||||||
|
|
||||||
|
var githubScriptContent = document.createElement('script');
|
||||||
|
githubScriptContent.innerHTML = `
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'G-C44R8LD9MC');
|
||||||
|
`;
|
||||||
|
document.head.appendChild(githubScriptContent);
|
||||||
|
|
||||||
|
// Netlify
|
||||||
|
var netlifyAnalyticsScript = document.createElement('script');
|
||||||
|
netlifyAnalyticsScript.async = true;
|
||||||
|
netlifyAnalyticsScript.src = 'https://www.googletagmanager.com/gtag/js?id=G-0R2ZXFSYVT';
|
||||||
|
document.head.appendChild(netlifyAnalyticsScript);
|
||||||
|
|
||||||
|
var netlifyScriptContent = document.createElement('script');
|
||||||
|
netlifyScriptContent.innerHTML = `
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'G-0R2ZXFSYVT');
|
||||||
|
`;
|
||||||
|
document.head.appendChild(netlifyScriptContent);
|
||||||
|
|
||||||
|
// Render
|
||||||
|
var renderAnalyticsScript = document.createElement('script');
|
||||||
|
renderAnalyticsScript.async = true;
|
||||||
|
renderAnalyticsScript.src = 'https://www.googletagmanager.com/gtag/js?id=G-MND1TVBSXV';
|
||||||
|
document.head.appendChild(renderAnalyticsScript);
|
||||||
|
|
||||||
|
var renderScriptContent = document.createElement('script');
|
||||||
|
renderScriptContent.innerHTML = `
|
||||||
|
window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', 'G-MND1TVBSXV');
|
||||||
|
`;
|
||||||
|
document.head.appendChild(renderScriptContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the function to add Google Analytics tags
|
||||||
|
addGoogleAnalyticsTags();
|
Loading…
x
Reference in New Issue
Block a user