Ready to up-Level your website for for the New Year? Join 'The Website Formula'

How To Add Header & Footer Code To A WordPress Website

Adding a header and footer code to your Wordpress website can be daunting. When using Google Analytics, a Facebook Pixel or a Cookie Script, you are going to need to add a little bit of code to your website. In this video, I’m going to show you an easy way to add code into your header or footer without writing any code at all, or editing any of your theme files.
Play Video

Video Transcript

Hey everyone, I’m Kelly, creator of the “Website Formula”, and today I’m going to teach you an easy way to add code into your header or footer without writing any code at all, or editing any of your theme files.

If you have a WordPress website and you want to use Google Analytics or add your Facebook pixel or a cookie script, then you’re going to need to add a little bit of code to your website, but you can’t do this with WordPress out of the box. 

Ways to Add Code

There are three ways you can do this:

  1. Manually, which means you have to edit your themes header.PHP and footer.PHP files, which probably sounds quite complicated. It’s also a little risky and these can be overwritten if your theme gets an upgrade, and you do want to be upgrading your themes, so it’s probably not the best route to go. 
  2. You can also do it through your theme’s built-in headroom footer code feature if your theme has one.
  3. The third way is by using a plugin. I’m going to show you how to do it using a plugin, but it’s worth checking if your theme has the functionality built-in already, and you can do this by going to your ‘dashboard’, ‘login’, and then going down to ‘appearance’ and ‘customize’. Over on the left, if you can add header and footer scripts, it could be in there. That’s a good place to check before you upload a plugin. 

If you can’t do it through your Theme, what you will need to do is install a plugin. 

Installing Plugins

Go to plugins and click on ‘Add New’, and that will search for plugins. Search for header and footer script, and you should get a few options here, but the one I use on all of my websites is, ‘Insert headers and footers by WPBeginner’, and as you can see it’s got over a million active installations, so that’s a good sign that it’s a good plugin. 

Click on ‘Install Now’, click on ‘Activate’ and your plugin will be activated. 

Now to enter some code. All I need to do is go down to ‘Settings’, then down to ‘New menu item’, click on ‘insert headers and footers’, and now I have three options so I can add a script into my header, a script into the body. If a script tells you to add it after the body tag, you would put it into there, and the footer as well.

Google Analytics Example

Let’s take Google Analytics for example. If you wanted to install Google Analytics on your own site, then you just need to come to and register and set up your account. Once you’ve done that, come down to ‘Admin’ on the left, and then to ‘tracking info’, and then ‘tracking code’, and you’ll get a little bit of script (see video), which says, “Copy and paste this as the first item into your head of every webpage you want to track.” It must be first because this is Google Analytics and you want it to track everything that happens on your websites, you don’t want any other scripts interfering with it. The only script I would put before Google Analytics is a cookie script because cookies need to have priority over all the scripts, so someone can opt-out of being tracked for cookies. 

Copy and Paste

All I then need to do is copy the code, which I haven’t had to write, and don’t have to insert it into the head of every webpage myself, because this does that for me, so anything that’s in the header will show on every single webpage I have on my website. 

I click in the header code box and I can right-click to paste or ctrl+V and it will be added in. I don’t suggest you change anything in here, I’d leave everything as it is. The orange script at the top is a comment, which tells you what this particular script is. So if you had one for Pinterest, or you had one for Facebook pixel, they would all be in here and you could tell which one was which, and if you wanted to remove one you could easily. 

Finishing touches

When you’re finished, click on ‘Save’ to update it and save it to your website: Google Analytics are now active. The best thing about this plugin is that you can add as many scripts as you want, so next time you’re trying to set up Google Analytics, or integrate with Facebook or Pinterest you’ll be ready to go, and it will only be a 30-second job. 

Thank you so much for watching. It’s been really lovely to have you here, and I’ve got a whole playlist of WordPress tutorial videos. So be sure to go and check them out if you have a WordPress website. And don’t forget to like, and subscribe, and I will see you again soon.

Kelly Sparkes Headshot in Circle

Hi, I’m Kelly, the digital bloomsmith behind Opal & Onyx. I specialise in creating websites showcasing your floral artistry and attracting and converting high-ticket customers, taking care of all the boring tech stuff.

Let’s collaborate to make your online presence as captivating as your blooms – I’d love to help your floral business flourish in the digital world.

View more


Sign up to my


Shop website


Peony and Peridot Home page without workshops section

Peony & Peridot

A sleek, flowing WordPress site full of large images; Peony & Peridot’s horizontal lines create a sense of space and openness, encouraging visitors to scroll and explore, diving deeper into the wonderful world you have created.
Jasmine and Jasper homepage in full

Jasmine & Jasper

The perfect balance of Passion & Luxury; Jasmine & Jasper’s elegant, minimalist layout will entice your clients in and keep them entranced with its unapologetically feminine allure.

Share the



Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like...

Georgina Chapman Flowers website updated hero image for Christmas

Preparing Your Website for Christmas – A Comprehensive Guide

The festive season is fast approaching, and if your business is in e-commerce or any industry that experiences a surge in Christmas traffic, preparing your website for Christmas is a crucial step. To make the most of this festive season, consider implementing the following key strategies and tasks that will

Read More
three generic logos designed with ai

Using AI to Generate Your Logo: 3 Costly Mistakes

Creating a compelling logo for your business has never been easier thanks to the advent of artificial intelligence (AI) tools and design templates. Platforms like and Canva offer efficient solutions for logo generation, helping you save time and money. However, whilst these AI-driven options can certainly be a game-changer,

Read More

Join the List

Join our thriving community of fellow floral enthusiasts by subscribing to our blog.

As a subscriber, you’ll be the first to unlock our website tutorials and insider tips, stay updated with the latest website trends, and gain access to exclusive discounts and content that will help you level up your website.