How to add code to the header in wordpress

If I could share a few words of encouragement to all of my fellow moxie mamas out there (by moxie mama I mean female entrepreneurs navigating their way to their dreams with grit, grace and determination), it would be:

Don’t be scared to break things.

Let me back up and share a little story about a little girl who got her first computer at home. Okay so it didn’t actually belong to her, it was the entire family’s. Annnnnddd she was only allowed so many minutes per day on it, annnnnddd she had to take turns with her two older sisters, just horrible conditions I tell ya.



While her friends might be doing things like playing Oregon Trail, she would be doing something less popular at the time…trying to break the computer. I mean, not literally, but I (cause by now we know she is me) would click the Start Menu, click the first option, open it up and click and unclick on every single thing I could…ya know, just to see what happened. If I broke the computer, I would quickly figure out how to undo what I did before my minutes were up. Once I figured out what one thing did, I clicked the next and so on. And yeah, sometimes I took a break to play Oregon Trail. For some reason my boyfriend at the time, who was always in the game of course, always got dysentery and died. I guess it was not meant to be.

I share that story with you because the entire foundation of my future computer-based career was based upon breaking things and then figuring out what the heck I did wrong. So, don’t be scared…you’ve totally got this, moxie mama.

Now, let’s talk about that WordPress head tag. I get this question a lot: Where do I put the code for Google Analytics, or Adsense, etc.

In this article I will show you how to find and add code to the head tag within WordPress.



As always, I want to serve both my friends who learn better via written instructions and those who prefer to learn via video, so I cozied up on my couch and made you this quick video tutorial and placed the written instructions below.

How to Add Code to Your Head Tag in WordPress

  1. First things first, make sure you have copied the code that you want to place into your head tag. For example, from Google Analytics or Adsense.
  2. Login to your WordPress dashboard, and go to Appearance, then Editor.

    Add Code to head tag in WordPress

  3. This is where a lot of people get scared. They see this big scary message and they bail. Don’t bail. Hear me out. This area is going to vary depending upon your theme. You may see the Theme Header (header.php) file on the right hand side in the list of files. Or, you may be defaulted to a child theme and only see 1-3 files on the right. If the latter is the case, then select the parent theme that you are using.

    How to Add Analytics or AdSense Code to Your Header in WordPress

  4. You are looking for the Theme Header (header.php) file on the right hand side in the list of files. When you find it in the list, click to open it. And then don’t be afraid of the warning message. Click Proceed.

    Edit Header File in WordPress



  5. Next, you’ll find the head tag. If you don’t spot it immediately, type Ctrl + F on your keyboard. A little search box will pop up, then type in /head. Your screen will highlight the close of the head tag. You will enter your code above this line.

    How to find the head tag in WordPress

  6. Finally, paste your code. I also suggest adding notes at the start and end of the code, so that you can easily find, edit, or remove the code later if needed and you won’t be confused as to where each section of code starts and ends. You can add notes that won’t affect your code by placing the note inside a tag as shown in this screenshot.

    Editing header in WordPress

  7. Once you’ve pasted in your code and added in your notes, click Update File. And you’re done!

Feel like you’re living on the edge now? If so, good! If not, that’s good too cause it’s really not a big deal, and now you know that!

I love to hear your feedback and try to answer all questions that I receive in the comments or at jessica@onmoxieandmotherhood.com







How to add code to the header in WordPress sites

Add code to header in wordpress

Hi, I’m Jessica! I am wife to Chris, and mom to Kaiper, Alana and our silver lab pup, Maui. We are expecting baby #3 right now, and excited to become a family of 5! I am a freelance website & blog developer, Co-Founder of Moxie Girl Fit Club, and aspiring author. I share about everything from parenting, how to make money from home, tutorials for my fellow bloggers, fitness and being a new homeschool family. Learn more about me here.