• Resolved wordpressnetwork

    (@wordpressnetwork)


    Hello guys,

    I try to include a js snippet in the script section, so that it only gets loaded when the user agrees.

    The original snippet is

    <script defer type="text/javascript" src="https://api.pirsch.io/pirsch.js"
        id="pirschjs"
        data-code="myid"></script>

    I know that one has to remove the script tags, as Complianz puts their own aroud it, so I did that and I put another ; after defer

    defer; type="text/javascript" src="https://api.pirsch.io/pirsch.js"
        id="pirschjs"
        data-code="myid">

    This results in

    <!-- Script Center statistics script Complianz GDPR/CCPA -->
                   <script  type="text/plain" data-category="statistics">
                       defer; type="text/javascript" src="https://api.pirsch.io/pirsch.js"
       id="pirschjs"
       data-code="myid"                </script>

    and does not work. Could you give me a hint what to do next? That would be much appreciated!

    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Rogier Lankhorst

    (@rogierlankhorst)

    As you want to control what’s in the script element (the data attributes), it’s better to put the script in without Complianz, directly in the html. Complianz just wraps the script tags around it without any attributes, as you can see.

    After embedding it yourself, you can block it in the script center, with “block script, iframe or plugin”.

    Then you can put in the script that should be blocked

    “api.pirsch.io”, set it to statistics, without placeholder, not an iframe.

    I notice that there are data attributes in the element (data-code=”myid”). If these are required for the script to run: We’re about to release an update which supports this.
    https://github.com/Really-Simple-Plugins/complianz-gdpr/tree/copy-script-attributes-to-target-script

    It will be included in the next update, until then you can use the above script.

    Thread Starter wordpressnetwork

    (@wordpressnetwork)

    Hello Rogier,

    thank you very much for your answer, it helps a lot! I will do as you suggested and will wait for the future update.

    Thanks a lot for your support,
    Stephan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include Tracking JS Code Correctly’ is closed to new replies.