DEV Community


Posted on

Gridsome, pushing "Google Analytics" code

I wanted to add Google Analytics on my website, Gridsome Plugin didn't work
plugin Google Analytics so I thought I can just insert this code in head / body on my page (, I make this:

    src:'<script async src=""></script><script>window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag(\'js\', new Date()); gtag(\'config\', \'UA-151506029-2\');</script>',
    body: true})

Local is everything ok but online I got an error in HTML below footer

" data-body="true">

I am beginner, so I don't know what is wrong

Top comments (2)

toledox82 profile image
Marcio Toledo

Hi mate,

I solved this issue adding the gtag code into the index.html.

Take a look:

But now have another gtag gridsome plugins too.

bibhuticoder profile image
Bibhuti Poudyal

Got stuck on the same issue and I did it manually 😂

Maybe this will help 🚀