Usually, these scripts will go in the header or footer section of your WordPress blog, so the code is loaded on every page view.
For example, when you install Google Analytics, the code needs to run on every page of your website, so it can track your website visitors.
You can manually add the code to your
footer.php files, but these changes will be overwritten when you update or change your theme.
The best plugin for the job is the Insert Headers and Footers plugin.
The first thing you need to do is install and activate the plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, you need to go to Settings » Insert Headers and Footers.
Here you will see three boxes for the header, body, and footer sections.
The plugin will now automatically load the code you added on every page of your website.
With this method, you need to add code to your WordPress files. If you haven’t done this before, then check out our guide on how to copy and paste code in WordPress.
First, we’ll show you how to add code to your WordPress site’s header. You need to copy the following code and add it to your functions.php, in a site-specific plugin, or by using a code snippets plugin.
Take a look at the following code snippet:
Take a look at the following example:
This code snippet hooks into
wp_footer instead of
To view it, you need to click on the three-dot menu in the top-right corner of the screen and then select ‘Options’ from the menu.
This brings up a popup where you need to check the ‘Custom fields’ option under the ‘Advanced panels’ section.
Then, click the ‘Enable & Reload’ button to reload the post editor.
After that, you’ll see the ‘Custom Fields’ meta box directly below the content editor.
Next, click the ‘Enter new’ link.
The custom field name and value fields will now appear.
Then, click the ‘Add Custom Field’ button to save your custom field.