Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #525180

    Hi, I need to add a facebook pixel code between <head> and </head>
    This is the code:
    <!– Facebook Pixel Code –>
    <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’,’//connect.facebook.net/en_US/fbevents.js’);

    fbq(‘init’, ‘1667760916779505’);
    fbq(‘track’, “PageView”);</script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=1667760916779505&ev=PageView&noscript=1&#8243;
    /></noscript>
    <!– End Facebook Pixel Code –>

    how/where I can do this?

    #525444

    Hi tchamp77,

    Please try the following in your child theme’s function.php:

    function facebook_function(){ ?>
    <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’,’//connect.facebook.net/en_US/fbevents.js’);
    
    fbq(‘init’, ‘1667760916779505’);
    fbq(‘track’, “PageView”);</script>
    <noscript><img height=”1″ width=”1″ style=”display:none”
    src=”https://www.facebook.com/tr?id=1667760916779505&ev=PageView&noscript=1″
    /></noscript>
    <?php
    }
    add_action('wp_head', 'facebook_function');

    Regards,
    Rikard

    #526499

    I also need to add the new pixel.. just to be clear would I copy the same code and just replace the numbers from above (ie 1667760916779505) to the ones on my pixel?

    Also when in functions php do I put it below the */ after template:enfold OR after /*Add your own styles here:*/

    Thanks

    #526730

    Hi,

    I’m not sure about the facebook scripts but you should be able to just replace the whole script block in the code above, if you’re copying the whole function then be sure to give the function a unique name as well, you will get errors otherwise.

    You should probably consider a child theme for your customisations, you will lose them on updates otherwise: http://kriesi.at/documentation/enfold/portfolio-item/create-a-child-theme/

    Thanks,
    Rikard

    #531181

    dear Rikard
    I saw i modified the original code facebok gave me.
    Where must I put your code in the functions.php?
    Plaese help me with this, I havent skills in programming
    Thanks

    #531759

    Hi,

    You can try it at the very bottom of your functions.php file. If you are not using a child theme then please consider doing so since you will lose any customisations on updates otherwise: http://kriesi.at/documentation/enfold/portfolio-item/create-a-child-theme/

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.