mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-29 17:32:43 +00:00
Use update ga script and support spa
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
"dependencies": {
|
||||
"@mcschema/core": "^0.4.0",
|
||||
"@mcschema/java-1.16": "^0.2.3",
|
||||
"@types/google.analytics": "0.0.40",
|
||||
"@types/split.js": "^1.4.0",
|
||||
"copy-webpack-plugin": "^6.0.1",
|
||||
"html-webpack-plugin": "^4.3.0",
|
||||
|
||||
@@ -285,7 +285,11 @@ Promise.all([
|
||||
}
|
||||
})
|
||||
|
||||
const reload = (target: string) => {
|
||||
const reload = (target: string, track=true) => {
|
||||
if (track) {
|
||||
ga('set', 'page', target)
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
selected = modelFromPath(target) ?? ''
|
||||
if (target) {
|
||||
history.pushState(target, 'Change Page', target)
|
||||
@@ -323,6 +327,6 @@ Promise.all([
|
||||
}
|
||||
updateLanguage(LOCALES.language)
|
||||
}
|
||||
reload(location.pathname)
|
||||
reload(location.pathname, false)
|
||||
document.body.style.visibility = 'initial'
|
||||
})
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-73024255-2"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-73024255-2');
|
||||
<!-- Google Analytics -->
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', 'UA-73024255-2', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
<!-- End Google Analytics -->
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
|
||||
Reference in New Issue
Block a user