gtm-module
gtm-module copied to clipboard
PageSpeed Insights Issue
Hey everyone, improved page speed on a project today but one issue seems to be difficult to solve. I'm using the awesome nuxt GTM module and loading it like this from nuxt.config.js:
gtm: {
id: '<my-ID>',
pageTracking: true
}
Google Pagespeed Insights tells me under "Remove unused JavaScript" the following items:
/gtm.js?id=<my-ID>(www.googletagmanager.com) | 26.2 KB | 12.5 KB
/analytics.js(www.google-analytics.com) | 18.6 KB | 6.7 KB
Is this caused by gtm module (which I don't think) or by GTM / Analytics / Pagespeed Insights itself?
Maybe you can help me, thank you very much in advance and I really appreciate it!
I also have the same concern on the page load speed. Please, tell us how to this can be optimized
Any update on this ?
Looks like this project is dead :(
@bart have you tried setting the scriptDefer
to true
? This should hold the loading of the GTM script until all other scripts are ready. It works for me.

And since I also enabled pageTracking
. In GTM i also make sure the tag is fired during the "nuxtRoute" custom event instead of the standard "Page View".

Here's my settings btw:
gtm: {
scriptDefer: true,
enabled: process.env.APP_ENV === 'production' ? true : false,
id: 'GTM-XXXXXX',
pageTracking: true,
}
Hey @rizkysyazuli sounds pretty good. Will try it out! Thank you very much. I'm already using the pageTracking option, too. Yay!
Hey @rizkysyazuli Its works, Thank you!, Just we need to add "pageTracking: true"