Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1102011
    Patrick
    Participant

    Hello,

    Can you please help me install the Facebook pixel base code to my child theme’s functions.php? I have read the instructions on this thread but am still not sure where the code should be pasted. I am assuming after the //Additional Functions line, but I’m not sure and don’t want to crash the site with a ppc campaign ongoing.

    I will send you my login and the fb code if you can assist me.

    Any feedback would be greatly appreciated.

    Thanks!

    #1102017
    Patrick
    Participant
    This reply has been marked as private.
    #1102043
    Rahul
    Moderator

    Hey there,

    Make sure that you have downloaded the latest version of child theme (https://community.theme.co/kb/how-to-setup-child-themes/).

    To setup Child theme properly, you need to follow this thread :

    https://community.theme.co/kb/how-to-setup-child-themes/

    Give it a try for once. If you are still facing any issues with it, let us know. We’d help you out!

    Thanks for understanding.

    #1102112
    Patrick
    Participant
    This reply has been marked as private.
    #1102132
    Rahul
    Moderator

    Hey There,

    Once a child theme is setup, please add this code in the functions.php file:

    function fb_pixel() {
    
    	if(is_page(2484)){
    	
    ?>
    	<!-- Your code will go here -->
    	
    <?php
       }
       
    }
    
    add_action( 'wp_head', 'fb_pixel' );

    Please add your FB pixel code around the area <!– Your code will go here –>.

    Hope this helps.

    #1114818
    milkshakerrr
    Participant

    Hello! Is it possible to add more than one pixel? Where would I input the subsequent pixel codes?

    #1115194
    Thai
    Moderator

    Yes,

    The code will be similar to this:

    function fb_pixel() {
    	if(is_page(2484)){
    	?>
    		<!-- Facebook Pixel Code 1 -->
    		<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');
    		// Insert Your Facebook Pixel ID below. 
    		fbq('init', 'FB_PIXEL_ID');
    		fbq('track', 'PageView');
    		</script>
    		<!-- Insert Your Facebook Pixel ID below. --> 
    		<noscript><img height="1" width="1" style="display:none"
    		src="https://www.facebook.com/tr?id=FB_PIXEL_ID&ev=PageView&noscript=1"
    		/></noscript>
    		<!-- End Facebook Pixel Code 1 -->
    
    		<!-- Facebook Pixel Code 2 -->
    		<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');
    		// Insert Your Facebook Pixel ID below. 
    		fbq('init', 'FB_PIXEL_ID');
    		fbq('track', 'PageView');
    		fbq('track', 'AddToCart');
    		</script>
    		<!-- Insert Your Facebook Pixel ID below. --> 
    		<noscript><img height="1" width="1" style="display:none"
    		src="https://www.facebook.com/tr?id=FB_PIXEL_ID&ev=PageView&noscript=1"
    		/></noscript>
    		<!-- End Facebook Pixel Code 2 -->
    	<?php
    	}
    }
    add_action( 'wp_head', 'fb_pixel' );

    Hope it helps 🙂

    #1217002
    milkshakerrr
    Participant

    Thank you!

    #1217065
    Friech
    Moderator

    You’re more than welcome, glad we could help.

    Cheers!

  • <script> jQuery(function($){ $("#no-reply-1102011 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>