[Vuejs]-Add external code to npm run build for index.html

0👍

If you use Vue CLI 3, you should have a src folder and a public folder. The public folder contains the index.html that is used to generate the index.html-file you see in the dist folder after building. Just add your tracker to that and it should be included in your built version as well.

You can also copy the tracker script to the mounted hook of App.vue, or whatever you use as your main component. Since your application will do nothing useful anyway when javascript is disabled, there is little reason to track that as well.

Leave a comment