How many times have you come across something that requires you to insert code into the head section of your blog? Perhaps you need to add Google Analytics tracking code. Or maybe you want to verify your Pinterest business account. Regardless of the reason why, you’ll likely have to do this at some time or another. And while it sounds scary and confusing, it’s actually quite easy. In this tutorial, I’ll show you how to insert code into the head section of your blog so you’ll be up and running in no time!
This post contains affiliate links. For more information, visit my disclosure page.
How to Insert Code into the Head Section With the Genesis Framework
If you’re using the Genesis Framework, you’re in luck! Inserting code into the head section of your site is ridiculously easy! Go to Genesis > Theme Settings. Scroll down to the bottom and find the section titled Header and Footer Scripts. Paste your code into the first box titled Header Scripts. Click save and you’re done!
How to Insert Code into the Head Section Using a Plugin
Not using Genesis? That’s fine. There’s still an easy way to insert code into the head section. First, you’ll want to install the Insert Headers and Footers plugin. From the Add Plugin page, search for “insert headers and footers.” You’ll want the plugin that was created by WPBeginner, which should be the first result. Install and activate it.
Now go to Settings > Insert Headers and Footers. Paste your code into the first box labeled Scripts in Header. Save and you’re done!
How to Insert Code into the Head Section of Your WordPress Theme
Now what if you’re not using Genesis and you’d rather not install another plugin? You’ll have to insert your code manually into your WordPress theme. Now keep in mind that doing so can break your site, so it’s important that you make a backup before you make any changes. Also, it’s important to note that when and if you install a theme update, your edits will be deleted and you’ll have to add them again. If you’re using a child theme, you should be okay, but if not, you might want to consider using the plugin mentioned above.
To insert the code manually into the head section of your WordPress theme, find your themes header.php file. You can find it by going to Appearance > Editor and looking for it on the right side of the screen. Or you can access it via FTP. Once you have your header.php file open, find the line with
Enter a new line above it and paste your code. Save your changes. That’s it.
Sidenote: Some themes will come with settings where you can enter your code into a designated area, much like the Insert Headers and Footers plugin above. It’s definitely a good idea to look into your theme’s documentation to see if that option is available. For example, the Divi theme has the option available by going to Divi > Theme Options, clicking on the Integrations tab, and entering the code into the box labeled “Add code to the < head > of your blog.”