I've configured the GA attribute in the config.js file with the ID, but I'm not seeing any evidence of it in the dev or build files.
https://github.com/bencodezen/vue-meetups/blob/master/docs/.vuepress/config.js
I expected some evidence of the following to appear in a build file or something, but I don't see any evidence of it in the files.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-123456"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-123456');
</script>
It seems like the configuration to integrate Google Analytics isn't working? Based on diving into the source code, it is generated based on (process.env.NODE_ENV === 'production' && GA_ID).
Is it possible that when triggering vuepress build docs it doesn't set the process.env.NODE_ENV to production which is why it is missing?
I might have figured it out. I think it has to do with the node_env flag. Will report back shortly.
Just tried adding a NODE_ENV variable with "production" as a value to the Netlify build process and it didn't seem to change the output.
@LinFeng1997 I'm currently waiting for Algolia to review the site. Is the Algolia configuration relevant to the Google Analytics though?
@bencodezen
In dev, that you cannot see it is due to the code won't be included to the output bundle:
if (process.env.NODE_ENV === 'production' && GA_ID) {
// GA's code
}
See: https://webpack.js.org/guides/production/#specify-the-environment
While in build, it should be in the output when you provide the GA's id:

Can't believe I missed it in there. I assumed it was in one of the other build files. Thanks for clarifying @ulivz!
Most helpful comment
@bencodezen
In dev, that you cannot see it is due to the code won't be included to the output bundle:
See: https://webpack.js.org/guides/production/#specify-the-environment
While in build, it should be in the output when you provide the GA's id: