Add conversion/tracking pixel to section for specific post

I need to add a tracking pixel for a Facebook ad to my WordPress site. It should only be active for one blog post, not for every page on the site.

How can I get the script into the HEAD section for the specific post only?

1 Answer
1

You can use the wordpress Conditional Tags

You can add something like this to your functions.php file:

is_single( 'your-post-slug' )
    add_action( 'wp_head', 'your_function_with_pixel' )

There are a number of different conditional tags you can use. And your-post-slug can be substituted with the post id as well.

Leave a Comment