Next.js Discord

Discord Forum

google tag manager

Unanswered
Nile perch posted this in #help-forum
Open in Discord
Nile perchOP
Hey guys, i finished a website and it incorporated google tag manager, but apparently it doesnt work, can someone help me set it up in next js and how can i know if it works. Thanks

8 Replies

Nile perchOP
https://stackoverflow.com/questions/76077818/how-to-add-google-tag-manager-to-a-nextjs-website

this talks about it, which could mean next js is the issue, ill send over the code i have for GTM soon
    <script
          dangerouslySetInnerHTML={{
            __html: `
              (function(w,d,s,l,i){
                w[l]=w[l]||[];
                w[l].push({'gtm.start': new Date().getTime(), event: 'gtm.js'});
                var f=d.getElementsByTagName(s)[0],
                j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';
                j.async=true;
                j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
                f.parentNode.insertBefore(j,f);
              })(window,document,'script','dataLayer','GTM-ABC123');
            `,
          }}
        /


<body>
 <noscript>
            <iframe
              src="https://www.googletagmanager.com/ns.html?id=GTM-ABC123"
              height="0"
              width="0"
              style={{ display: "none", visibility: "hidden" }}
            ></iframe>
          </noscript>
</body>
@Nile perch From my past experience, one thing to keep in your mind is that, GTM doesn't work right after your setup.
Always there is some delay, if you think your implementation is correct and you don't see those events in the dashboard - just wait!
i even readded them for the client and he said it still doesnt work
idk if its a issue i created or if its on his end but i have to fix it
Nile perchOP
anyone know what i should do