-
AuthorPosts
-
October 26, 2015 at 9:13 pm #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″
/></noscript>
<!– End Facebook Pixel Code –>how/where I can do this?
October 27, 2015 at 12:14 pm #525444Hi 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,
RikardOctober 29, 2015 at 2:24 am #526499I 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
October 29, 2015 at 1:40 pm #526730Hi,
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,
RikardNovember 5, 2015 at 8:50 pm #531181dear 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
ThanksNovember 7, 2015 at 7:40 am #531759Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.