Google analytics tracks the default title set in nuxt.config.js.
[issue link]Hi.
I track the site with Google analytics.
plugin/gtag.js
export default ({app}) => {
if (process.env.NODE_ENV !== 'production') return;
(function (win, doc, script, url) {
let a = doc.createElement(script);
let m = doc.getElementsByTagName(script)[0];
a.async = 1;
a.src = url;
m.parentNode.insertBefore(a, m);
})(window, document, 'script', 'https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxx-1');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxxx-1');
app.router.afterEach((to, from) => {
gtag('config', 'UA-xxxxxxxx-1', to.fullPath);
});
}
In most cases, this code works fine, but sometimes the title set in nuxt.config.js
is tracked instead of the original page title, when the page is initially displayed.
I want to track Google analytics at the time when vue-meta resolves the correct page title, what is the solution?
Could anyone help me?
Thanks.