-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a doc to teach how to let vitepress work with google analytics #1131
Comments
Refer https://vitepress.vuejs.org/config/app-configs.html#head You'll need to do something like: head: [
['script', {src: 'https://googletagmanager.com/...'}],
['script', {}, `gtag call here`]
] |
What does the first script do here |
It will be given in your analytics console. It loads [
[
'script',
{ async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX' }
],
[
'script',
{},
"window.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', 'G-XXXXXXXXXX');"
]
] Then this will be rendered: <script async='' src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script> |
I got it! |
update: [
'script',
- { async: true, src: 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX' }
+ { async: '', src: 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX' }
] Get the real header like: <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script> |
In my testing on <script async="" src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script> It would be great if booleans were allowed here, since |
|
x-ref: #1131 (comment), #2607 Co-authored-by: CaptainTeemo <alittlebarney@gmail.com>
x-ref: vuejs/vitepress#1131 (comment), #2607 Co-authored-by: CaptainTeemo <alittlebarney@gmail.com>
Is your feature request related to a problem? Please describe.
hope to use google analytics with VitePress
Describe the solution you'd like
add a doc to introduce or just do it for the vitepress docs so that we can learn from the code
Describe alternatives you've considered
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: