Title: Include Tracking JS Code Correctly
Last modified: December 1, 2022

---

# Include Tracking JS Code Correctly

 *  Resolved [wordpressnetwork](https://wordpress.org/support/users/wordpressnetwork/)
 * (@wordpressnetwork)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/include-tracking-js-code-correctly/)
 * 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 Contributor [Rogier Lankhorst](https://wordpress.org/support/users/rogierlankhorst/)
 * (@rogierlankhorst)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/include-tracking-js-code-correctly/#post-16252383)
 * 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](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.
    -  This reply was modified 3 years, 5 months ago by [Rogier Lankhorst](https://wordpress.org/support/users/rogierlankhorst/).
 *  Thread Starter [wordpressnetwork](https://wordpress.org/support/users/wordpressnetwork/)
 * (@wordpressnetwork)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/include-tracking-js-code-correctly/#post-16254640)
 * 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.

 * ![](https://ps.w.org/complianz-gdpr/assets/icon-256x256.png?rev=2881064)
 * [Complianz - GDPR/CCPA Cookie Consent](https://wordpress.org/plugins/complianz-gdpr/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/complianz-gdpr/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/complianz-gdpr/)
 * [Active Topics](https://wordpress.org/support/plugin/complianz-gdpr/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/complianz-gdpr/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/complianz-gdpr/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [wordpressnetwork](https://wordpress.org/support/users/wordpressnetwork/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/include-tracking-js-code-correctly/#post-16254640)
 * Status: resolved