Title: Help with js implementation
Last modified: July 29, 2022

---

# Help with js implementation

 *  Resolved [Tony Franco](https://wordpress.org/support/users/tony-franco/)
 * (@tony-franco)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/help-with-js-implementation/)
 * Dear Sirs,
 * Thank you by this plugin, it´s working fine!
 * Could you help me with an implementation of js?
 * I made an ‘if condition’ to call a script as below:
 *     ```
       add_action( 'wp_head', function() {
           ?>
       	    <script>
   
       if(document.querySelector('.class').innerHTML.includes('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')){
   
       			// i want to insert at html the facebook pixel, as example:
       ```
   
 * <script>
    !function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
   n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;
   n.push=n;n.loaded=!0;n.version=’2.0′; n.queue=[];t=b.createElement(e);t.async
   =!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(
   window, document,’script’,’[https://connect.facebook.net/en_US/fbevents.js&#8217](https://connect.facebook.net/en_US/fbevents.js&#8217););
   fbq(‘init’, ‘xxxxxxxxxxxxxx’); fbq(‘track’, ‘PageView’); </script> <noscript>
   </noscript>`
 * }
 *  </script>
    <?php });`
 * It not work at HTML inserting the code, even putting an escaping at <\/script
   >…
 * Do you know how this can work?
 * Thanks and Regards,
 * Tony

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/help-with-js-implementation/#post-15877603)
 * Hello,
 * Can you clarify what sort of condition you are trying to check with the `if` 
   statement?
 *  Thread Starter [Tony Franco](https://wordpress.org/support/users/tony-franco/)
 * (@tony-franco)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/help-with-js-implementation/#post-15877643)
 * Hi [@bungeshea](https://wordpress.org/support/users/bungeshea/)
 * Thank you by your return!
 * The if condition is for this:
 * When someone visit a post of website, if it contains a specific category it add
   the facebook pixel to the html, and the visitor is accounted to the public of
   that category in facebook, because the code is inserted there.
 * Or if you know an easier way, please say.
 * Regards,
    Tony
 *  Thread Starter [Tony Franco](https://wordpress.org/support/users/tony-franco/)
 * (@tony-franco)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/help-with-js-implementation/#post-15878285)
 * Hi [@bungeshea](https://wordpress.org/support/users/bungeshea/)
 * I have found another solution here..
 * Thank you by return and sorry by disturb.
 * Regards,
    Tony
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/help-with-js-implementation/#post-15890553)
 * Glad to hear you could get it sorted!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Help with js implementation’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/help-with-js-implementation/#post-15890553)
 * Status: resolved