Support » Plugin: GDPR Cookie Compliance (CCPA, PIPEDA ready) » GTM not working while adding code to 3rd party cookie section

  • Resolved nabaraj chapagain

    (@nabaraj-chapagain)


    The GTM wont fire any tags if we add the script in third party header section. If added directly to the header, which works perfectly!

    The reason for this is not loading the script to the header once clicked ‘accept’. Its added dynamically so wont work at all.

    How do we sort this issue.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Moove Agency

    (@mooveagency)

    Hi @nabaraj-chapagain,

    Thanks for using our plugins.

    Could you please provide more details about the issue?
    What is the script you are using on your website (you can replace the ID’s with custom XYZ strings)?
    What is your website URL where we can check the issue?

    You can check our related topics as well:
    https://wordpress.org/support/topic/white-screen-during-navigation/
    https://support.mooveagency.com/topic/website-re-loads-after-a-few-seconds-once/

    Hope this helps.

    nabaraj chapagain

    (@nabaraj-chapagain)

    Hello

    Thanks for the reply. Below is the GTM code

    <!– Google Tag Manager –>
    <script>(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-xxxxxxx’);</script>
    <!– End Google Tag Manager –>

    I’ve put this inside the third party cookie section. We’re trying to track some form submissions and button clicks.

    The GTM preview mode wont work. The code that is dynamically injected wont record any conversions.

    We cant directly add to code to header because of the cookie added by the GTM. And trying to make it GDPR compliance wont track anything after moved from header to the plugin header section.

    Any solution for this?

    nabaraj chapagain

    (@nabaraj-chapagain)

    Can you provide some updates please?

    Plugin Author Moove Agency

    (@mooveagency)

    Hi @nabaraj-chapagain,

    Please replace your GTM script with the following snippet, and place to the correct position (peplace the GTM-ZZZZZZ to your real ID):

    Third Party – Header Scripts

    <!-- Google Tag Manager -->
    <script>(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-ZZZZZZ');</script>
    <!-- End Google Tag Manager -->

    Third Party – Body Scripts

    <!-- Google Tag Manager (noscript) -->
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-ZZZZZZ"
    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) -->

    Also, please ensure the https://www.example.com/wp-admin/admin-ajax.php is not protected, so if you open in a browser, you should see a 0. Sometimes the wp-admin area is protected but the admin-ajax.php is not whitelisted and this causes the issue. If it’s protected and you can’t whitelist the AJAX in your website, you can add the following code snippet to your functions.php
    add_action( 'gdpr_cc_prevent_ajax_script_inject', '__return_true' );

    If none of the solutions listed above is working, please share your site URL in order to see the errors and start the investigation for you.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.