Where do I find the header.pxp file to paste this ? The google and AI instructions do not lead me to the correct place
Hi @Knode,
You may find Facebook’s pixel plugin an easier alternative:
Else, a plugin like this:
Will allow you to easily insert code snippets into your desired location.
I hope this helps!
Cheers,
Chris ![]()
Hey Chris, thanks. I had actually started doing this the first time with Meta pixel for WordPress plugin but then in Meta Business Suite it didn’t seem to be able to take the next step and was stuck at the step telling me to copy the base code and paste it in the header.pxp file so I decided to just try to do it that way. Have you had success with either of those plugins?
Hi,
In general, there is no need to directly edit theme or plugin files. If you need to add custom code to the site header, you can use the following approach:
add_action('wp_head', function() {
?>
<!-- your code here -->
<?php
});
If the code needs to be added at the beginning of the <body> tag, you can use:
add_action('wp_body_open', function() {
?>
<!-- your code here -->
<?php
});
And if it needs to be added to the footer (before the closing </body> tag), you can use:
add_action('wp_footer', function() {
?>
<!-- your code here -->
<?php
});
You can use plugins like Code Snippets to add custom PHP without modifying any core files, or plugins that Chris suggested.
In many cases, analytics plugins also provide built-in options for Google Analytics, tracking pixels, and similar integrations, so it’s worth checking those as well before adding custom code.
Hope this helps
Okay. How do I get to the header location to add the code?
Hi @Knode,
The PHP snippets shared by Kseniia above can be added easily using a plugin like:
You can learn more about adding code snippets here:
I hope this helps!
Cheers,
Chris ![]()
Okay - I think I understand the various options now. Of course, it looks like the pixel is set up when looking in business suite/events manager now.
What is the best recommended approach to do this? Using Code Snippets plugin?
You don’t need to locate and edit the header.php file directly.
Instead, you can use a plugin such as Code Snippets and add the suggested snippet there, depending on where you’d like the pixel to appear (header, beginning of the body, or footer).
In short, the Code Snippets plugin allows you to add custom functionality and hook into WordPress/HivePress without modifying theme files directly. This approach is generally easier to maintain, and won’t be affected by theme or plugin updates.
Okay great I will do it that way! Thank you Kseniia and Chris ![]()