- This topic has 7 replies, 3 voices, and was last updated 7 years, 1 month ago by Leo.
-
AuthorPosts
-
March 17, 2017 at 8:53 am #293427Helen
Hi there,
I’ve placed my base Facebook pixel code in the wp_head section in GP Hooks. Does the execute PHP box need to be ticked?I expect that the above will post the pixel code to every page, but is there also a way to post a different pixel code to a specific page, for example a custom event pixel for sign-up page?
Many thanks for your help,
Helen
ps – Happy St Patrick’s Day from Ireland!March 17, 2017 at 8:56 am #293430LeoStaffCustomer SupportHi Helen,
Can you share the code you used on here?
Thanks.
March 17, 2017 at 10:13 am #293484TomLead DeveloperLead DeveloperHappy St Patrick’s Day! ๐
If you need it to show up on specific pages, you would need to use PHP.
For example:
<?php if ( is_page( 'my-page-slug' ) ) { ?> Your FB pixel code for yourwebsite.com/my-page-slug <?php } ?>
March 18, 2017 at 5:31 am #293791HelenMany thanks for your replies. The code I’ve placed in wp_head is below, it was copied from Facebook’s pixel helper and is for my basic pixel.
<!– 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’,’https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘123mypixelcode’); // Insert your pixel ID here.
fbq(‘track’, ‘PageView’);
</script>If I want to add a specific pixel to a single page I would add Tom’s code underneath and tick the execute pho box, is that correct?
So my code in wp_head is now:
<!– 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’,’https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘123mypixelcode’); // Insert your pixel ID here.
fbq(‘track’, ‘PageView’);
</script><?php if ( is_page( ‘my-page-slug’ ) ) { ?>
Your FB pixel code for yourwebsite.com/my-page-slug
<?php } ?>Is that correct?
Many thanks indeed for your help,
Kind regards,
HelenMarch 18, 2017 at 6:10 am #293804LeoStaffCustomer SupportHi Helen,
You would first want to replace the “Your FB pixel code for yourwebsite.com/my-page-slug” from Tom with the actual facebook code (from
<script>
to</script>
).Then replace “my-page-slug” with the actual page slug that you want to apply the facebook setting.
Let us know if this is clear.
March 18, 2017 at 9:35 am #293901TomLead DeveloperLead DeveloperIt might be easier to use a plugin: https://en-ca.wordpress.org/plugins/oh-add-script-header-footer/
This way you can just add your FB code onto the pages you want it to appear ๐
March 18, 2017 at 10:56 am #293942HelenThanks Leo and Tom,
That’s very clear and helpful. I’ll try both ways and post here again if I can’t get one of them going.
Cheers,
HelenMarch 18, 2017 at 3:01 pm #294036LeoStaffCustomer SupportGlad we could help!
-
AuthorPosts
- You must be logged in to reply to this topic.