Site logo

Archived topic

Tracking Pixel on one page

4 replies · Started by Sarah on February 13, 2017

Viewing posts 1–5 of 5

Hi Tom, I need to add a Facebook event tracking pixel on one page of a site only - how would I do this? It needs to go before the closing </head> of the page.

I've got the standard pixel on all pages via webhooks but don't know how to add this extra script on just the page that is relevant for the event.

Thanks for your help! :)

Hi Sarah,

I think you would use the Before Header Hook: https://docs.generatepress.com/article/hooks-overview/

and do something like this:

<?php if ( is_page( 'page-slug-here' ) ) : ?>
    insert Facebook event tracking pixel
<?php endif; ?>

Make sure Execute PHP is checked.

Let me know if this helps.

If it needs to go before the closing </head>, you would use the wp_head hook.

Other than that, Leo nailed it :)

Thanks Leo and Tom! It needs to go directly after the closing </head> so I'll put it in the After Header hook and give it a whirl.

Glad we could help!

This archived topic is closed to new replies.