[Resolved] Tracking Pixel on one page

Home Forums Support [Resolved] Tracking Pixel on one page

Home Forums Support Tracking Pixel on one page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #278095
    Sarah

    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! ๐Ÿ™‚

    #278178
    Leo
    Staff
    Customer Support

    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.

    #278223
    Tom
    Lead Developer
    Lead Developer

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

    Other than that, Leo nailed it ๐Ÿ™‚

    #278493
    Sarah

    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.

    #278654
    Leo
    Staff
    Customer Support

    Glad we could help!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.