Add Your Analytics Tracking Code to Your Header.php File

To add your Google Analytics tracking code to your header.php file, log in your WordPress back office and scroll down to the Appearance tab, then click on Editor. Now, click on the header.php file which is located on the right-hand side of the editor page under Templates.

Now, paste the tracking code you’ve already copied from Analytics before the </head> tag. Click on the Update File button.


How to Add Your Google Analytics Tracking ID to Your WordPress Website

You just learned how you can add Google Analytics code to your WordPress site. However, if you don't want to insert any code at all on your site, you can alternatively copy your tracking ID and paste directly in the appropriate box in your WordPress dashboard.

Click on the "All in One SEO" tab which is located on the left-hand side of your WordPress dashboard. Select General Settings and scroll down to Google Settings. Locate the Google Analytics tracking ID box and paste your tracking ID. Now, scroll down to the bottom and click on Save Changes. You can then begin to track your visitors without inserting any code at all.



Join the Discussion
Write something…
Recent messages
Karax Premium
the only downside of adding the code in the header.php is that it has to be re-added once there is a theme update.
Reply
Israel17 Premium
You're very correct, Karax, that adding Analytics code to the header.php file would surely warrant redoing the same whenever there's a cause to switch between themes. And that was why I recommended in my training tutorial that you can simply add your Google Analytics tracking ID to your site without having to insert any HTML code at all. Thanks for stopping by!

Israel Olatunji
Reply
Karax Premium
Thank you for the insightful post! Is it worth installing the free version of MonsterInsights? I read in the plugin reviews that the free version is worthless. Is it the case or it works fine?
Reply
Israel17 Premium
Thanks for asking, Karax! Not at all, you don't need to install the MonsterInsights plugin on your site. Just the adding of the Analytics tracking code will do a great job for you. Thanks for visiting!

Israel Olatunji
Reply
mcb247 Premium
Thanks for a great article ... Bookmarked !

Martin
Reply
Israel17 Premium
Thanks for your comment, mcb247! Kudos for the readings and for bookmarking my training resource! Much impressed! It's the practice of the pros to log in to Analytics on an everyday basis. If you want to become a pro, then you must follow the pros. Thanks for the lovely visit!

Israel Olatunji
Reply
lesabre Premium
Here I go again another bookmark and another Thank you.
Reply
Israel17 Premium
Much welcome, lesabre! Thanks for stopping by and for deciding to bookmark this resource! Much appreciated! Adding Analytics code to one's website enables one to track visitors and to evaluate real-time stats easily. See you at the top of the online world soon!

Israel Olatunji
Reply
1signbanner Premium
Israel, your blog came at such a right time for me. I understand the importance of 'links' being a launching pad to external sites are looked down upon by Google. I knew what I needed to do, to make visitors 'roam' on my site, but this blog you create my brother is the details I need to know. Thank you!

As I have always said and believe, Israel, you are sooo welcomed in my journey to creating an awesome website. In fact you play a BIG PART to my success, my dear friend.

I know I missed a ton of your education, but nothing gets passed me. I do cherry pick those that, at the time, are important for me to learn.

I., I am a slow learner. With your unlimited and powerful braincells you have, I can only fill my head with so much to be absorbed into my quite empty head. =)

I am not intimidated my brother, I accept myself for who I am.
No worries my brother I am still confident and proud. lols!

Thank you Mr. Ambassador. You rock my brother!

frank =)
Reply
Israel17 Premium
Wow, thanks for your lovely comment and for the awesome compliment, 1signbanner! I'm more than excited to know that my training resources have been of help to an awesome friend like you.

You have boosted my morale today more than ever and you've given me a challenge to be more committed to this work for the growth of others in this business. Wish you much success in your online endeavors! See you at the top of the online world, my lovely brother! Success is guaranteed! Please, keep it up, brother.

Israel Olatunji
Reply
1signbanner Premium
You are much welcomed, Israel. Your work is not going unnoticed. Far from it, you do have an impact to many others such as myself. I AM NOT ALONE MY BROTHER!

TRUST ME, I THINK IT'S TRUE!

Keep doing what you are doing, members here sorely need your classes, TEACHER! =)

frank
Reply
Terand Premium
Thank you for the teaching, Israel! I' ve bookmarked it first as still dare not try on the code yet :o)
Reply
Israel17 Premium
Thanks for your lovely comment, Terand! Kudos for the reading and for your passion! Without adding Google Analytics code to your website, you won't be able to track your visitors. However, you may decide not to add tracking code but the tracking ID to your WordPress site rather. Thanks for your lovely visit!

Israel Olatunji
Reply
Terand Premium
Sure, Israel! Need to check it out again as I need to prioritize on my article/training task. Ha :o)
Reply
Israel17 Premium
Alright, Terand! Please, do. You need to prioritize article-writing which is the basis. Wish you much success in your online endeavors!

Israel Olatunji
Reply
Terand Premium
Yes, Israel! Thank you for advice! :o)
Reply
Top