WordPress: Add Code to Header and Footer

Often you need to add code to WordPress header and footer when trying to integrate with web services like Google Analytics, Google Search Console, etc. The easiest way to add code to the WordPress header and footer is via a plugin called WPCode:

  1. Login to your WordPress Dashboard and go to Plugins > Add New.
  2. Search for the WPCode – Insert Headers and Footers + Custom Code Snippets plugin > install and activate it
  3. Go to Code Snippets (left column) and select Header & Footer (see the screenshot below).
  4. If you have to insert any code between <head> and </head>, add it to the Header box.
  5. If you have to insert any code just below <body>, add it to the Body box.
  6. If you want to add a code above </body>, add it to the Footer box.

Once you’re done, don’t forget to click the ‘Save Changes‘ button to save your settings.