nuxt-modules / partytown

Partytown integration for Nuxt. Run third-party scripts from a web worker.
MIT License
316 stars 8 forks source link

Unable to view structured markup and GTM in debug mode #325

Closed guptritik146 closed 1 year ago

guptritik146 commented 1 year ago

Hi, I tried deploying partytown with our laravel website. I added Google analytics code inline and added datalayer.push in forwards. I managed to remove the CORS error by adding GA inline but now after deploying partytown in production, I am unable to view GTM events in debug mode. Neither am I able to view which events are getting fired and the structured markup has also disappeared from the pages. Please help 🥲 Here is my Partytown config: <script> partytown = { forward: ['dataLayer.push', 'gtag'], }; </script> My GTM Script: <script type="text/partytown">(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-XXXXX'); </script> Here is my google analytics script:

<!-- Google Analytics Code -->
        <script type="text/partytown">
            (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            })(window,document,'script','http://lexample.com/js/google-analytics.js','ga');

            ga('create', 'UA-XXXXX-1', 'auto');
            ga('send', 'pageview');
        </script>
        <!-- End Google Analytics Code -->