Support » Plugin: GDPR Cookie Compliance » Code Not Inserting Into Head Section Once Visitor Accepts Cookies

  • Resolved tcress101

    (@tcress101)


    I’ve been playing with this all night and even tried the very latest update from tonight (1.0.9?)

    I’m trying to add code snippets for analytics software and ad management software into the boxes (under 3rd party cookies and additional cookies) that say: “The below script will be added to the page HEAD section if user enables this cookie” but nothing is inserted on the page once a visitor accepts the cookies. I double check View Source on the page and nothing’s been added. I’ve cleared web cache. Nothing helps.

    I’m just copying & pasting the code directly from the programs I’m using, should I be formatting the code differently?

    For example:

    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
    gtag('config', 'UA-XXXXX');
    </script>
Viewing 3 replies - 16 through 18 (of 18 total)
  • mikkelhusum

    (@mikkelhusum)

    @oramweb

    It seems that the plugin itself adds the script through JavaScript, so it wan’t be visible in the source code but still be inserted (https://wordpress.org/support/topic/google-analytics-code-not-added/).

    But the above code still works fine, and if you want to disable a Facebook Pixel plugin depending on which settings the user chooses in the popup, you can do it with the above code.

    oramweb

    (@oramweb)

    @mikkelhusum

    True story, find out it right now.
    Thanks!

    Hi there,

    Thanks for your comments. Our plugin loads the script with Javascript, and that’s why you can’t find it in the view-source page. You can try the developer console in Chrome (inspect element) and find the scripts.

    I hope this helps.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Code Not Inserting Into Head Section Once Visitor Accepts Cookies’ is closed to new replies.