Tagged: header
-
AuthorPosts
-
May 23, 2016 at 6:57 pm #637018
I want to add the Facebook Conversion Pixel to the header of a single page on my site. I know how to add the Google Analytics code to my site, but that adds the code to every page. The Facebook Conversion Pixel has to be added to the header of only the conversion page. How do I do that? And I really would prefer not to do it with a plugin.
I’m seeing other comments about adding script to the functions.php file. Can this be done for just a single page with the page ID? Can you give me exactly what code should be added to the functions.php file and where to change the page ID? Thanks
- This topic was modified 8 years, 6 months ago by TheURLdr.
May 23, 2016 at 9:57 pm #637091Hey Kim!
Add the following to your header page
<?php if is_page('page_id'); { ?> the code here <?php } ?>
let us know if that helps you out
Best regards,
BasilisMay 23, 2016 at 10:01 pm #637093Thanks Basilis, but I have no idea what that does. It’s obviously only a piece of what needs to be done, but I have no idea what to do from here. Can you please explain exactly what that does and what else I need to do?
May 23, 2016 at 11:18 pm #637124Hi,
Thanks for getting back to us!
In the code example Basilis gave you need to add your Facebook Conversion Pixel code and the ID number of the conversion page.
So when adding the code to the header file change the following that is in bold:
<?php if is_page(‘page_id‘); { ?>
the code here
<?php } ?>
If you still need assistance let us know.Best regards,
JordanMay 27, 2016 at 10:10 pm #639527Jordan,
Thanks for clarifying the code, but I’m still confused where to put this. The only place I know to put the code is in the functions.php within the child theme. Basisilis is saying to add it to “your header page.” How would I do that?Update – I tried adding this to the functions.php file and it broke the page in question.
- This reply was modified 8 years, 5 months ago by TheURLdr.
May 30, 2016 at 6:34 am #640137Hi,
You can find the header.php file in the Appearance > Editor panel. However, in order to preserve this modification, you have to duplicate the header.php file in a child theme if you have one and add the modification so instead of doing that, edit the functions.php file then insert this code:
function ava_fb_px_conversion(){ if ( is_page( PAGE ID HERE )) { ?> FACEBOOK PIXEL COVERSION CODE HERE <?php } } add_action('wp_head', 'ava_fb_px_conversion');
If you can give us the FACEBOOK PIXEL CONVERSION snippet, we’ll complete the code for you.
Best regards,
IsmaelMay 30, 2016 at 6:48 am #640139Hi,
You can try this in your functions.php file, if that doesn’t work then please post the exact code you want to add:
function enfold_add_facebook_pixel(){ if is_page('page_id'); { ?> the code here <?php } ?> } add_action('wp_head', 'enfold_add_facebook_pixel');
Regards,
RikardDecember 19, 2017 at 1:42 pm #890475Hi
How can I use the function for a portfolio post?
I have tried
function enfold_add_facebook_pixel(){
if is_single($post = ‘5412’); {
but is breaking the website
Thank youSolved Thank You Anyway
function ava_fb_px_conversion(){
if ( is_single( 5412 )) {
?>
<!– Facebook Pixel Code –>- This reply was modified 6 years, 11 months ago by manurimini.
December 20, 2017 at 5:56 am #890694 -
AuthorPosts
- The topic ‘Adding tracking code to the header on a single page’ is closed to new replies.