• Resolved Tony Franco

    (@tony-franco)


    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;);
    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

    (@bungeshea)

    Hello,

    Can you clarify what sort of condition you are trying to check with the if statement?

    Thread Starter Tony Franco

    (@tony-franco)

    Hi @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

    (@tony-franco)

    Hi @bungeshea

    I have found another solution here..

    Thank you by return and sorry by disturb.

    Regards,
    Tony

    Plugin Author Shea Bunge

    (@bungeshea)

    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.