• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Nile Flores Media

Helping You Rock Out Your Website Like A Rockstar

  • Home
  • About
  • Blog
  • Portfolio
  • Hire Me
  • Resources
  • Contact
  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design
  • News
  • Podcast
You are here: Home ยป WordPress ยป How To Set Up Google Analytics In WordPress

How To Set Up Google Analytics In WordPress

By Nile Flores 9 Comments


google-analytics-for-wordpress-thumbnailGoogle Analytics is just about a standard necessity to have when creating a website, especially for web stats. A lot of new website owners aren’t sure where to implement it, especially with WordPress.

Google has developed their Analytics product to help you track as much of your website, as well as social engagement. Below are two ways on how to set up Google Anaytlics in WordPress.

How To Set Up Google Analytics In WordPress – Without A Plugin

If you are comfortable editing your theme’s template files and prefer to not use a plugin, then this method is for you.

Below is a general generated tracking code from Google Analytics.

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA- ', 'yourdomainname.com');
  ga('send', 'pageview');

</script>

Replace the UA with your analytics ID that Google gives you. Note: If you’re having issues finding the tracking code, go log into you Google Analytics account, and then under Admin> Tracking Info> Tracking Code. Copy that as it has your Analytics ID in the code.

However, if you know your Analytics ID for your website, replace the yourdomainname.com with your site’s domain.

Add the code to your header.php file in your theme folder before the ending </head> tag. If you prefer to place it in the footer, find your footer.php file and place it before the ending </html> tag, but after the </body> markup tag.

You could also create a file called googleanalyticstracking.php, paste the above code, and then include the line

<?php include_once("googleanalyticstracking.php") ?>

Again, this file can be placed in the same areas specified above.

How To Set Up Google Analytics In WordPress – With A Plugin

google-analytics-for-wordpress-plugin-image

If you don’t want to mess with touching any code except copying and pasting your Analytics ID for your website, then Google Analytics or WordPress by Joost de Valk would be a great and easy solution to use.

Once you’ve installed the Google Analytics for WordPress plugin, you can sync your Google Analytics account with it.

google-analytics-screenshot-1

The options for Google Analytics for WordPress are fairly cut and dry. The plugin basically asks you on what you want to track or not to track. All you do is select what you want to track and save. ๐Ÿ™‚ If you need to track more, there are some really in depth settings to track things like Internal links, outbound links, authors, logged in users, post types, categories, downloads, and much more.

google-analytics-screenshot-2 google-analytics-screenshot-3

Of course, there are a ton of other Google Analytics related plugins, but this one does a lot to help you track as much of your site as possible. For some, having all of these options at their disposal may be intimidating, but that’s okay. With a little time and learning, anyone can take advantage of all of the features of the Google Analytics for WordPress plugin.

Have you installed Google Analytics on your WordPress powered website? If so, what method did you use? If you used a plugin, did you use the one mentioned above?


Filed Under: WordPress Tagged With: google, google analytics, google analytics for wordpress

About Nile Flores

Nile is a 43-year old female from the greater St. Louis (Southern Illinois side) area. Nile is a mother of 1 son. She is also a web designer and developer, a graphic designer, and a public speaker, who exclusively designs and develops using WordPress. She also blogs at GoDaddy's Blog, Verpex Hosting's blog and her very personal sites, Pixelled and Nail Polish Happy.




Related posts:

WordPress Plugin Review: Google Analytics For WordPress

Reader Interactions

Comments

  1. Kaloyan Banev says

    March 10, 2014 at 2:34 am

    It is quite easy, I think most bloggers do it with plugin. Though recently I see GA stats as highly inaccurate when I am comparing with other tools and server logs.

    Reply
  2. Robert says

    March 10, 2014 at 11:32 am

    Great tutorial thanks. I need to know how to do it for a bigcommerce website. Can you please tell me??

    Reply
    • Nile says

      March 10, 2014 at 11:06 pm

      This is for WordPress… if your e-commerce site has it’s own template files that you can edit and place the code within, or perhaps some type of add-on or module, you may be able to implement it.

      Reply
  3. Dean Saliba says

    March 10, 2014 at 5:34 pm

    I’m pleased to see you have mentioned that you can set this up with a simple plugin, I have been using Google Analyticater plugin for a couple of years now and I couldn’t see myself EVER going back to the old way of inserting the code into the header file of my theme. ๐Ÿ™‚

    I love how I can set it up to show the stats on my WordPress admin panel, so I don’t have to navigate to my Google Analytic account all the time. ๐Ÿ™‚

    Reply
  4. jawad zaib says

    March 14, 2014 at 12:20 pm

    Most new themes have the option to insert the code inside the theme panel but using the GA plugin might work well,,, i didn’t used this but i just saw the review on this blog and now will give the plugin a try and will see how it will work for me,,,,,

    Reply
  5. sofiherrla says

    March 18, 2014 at 3:54 am

    It’s a very easy use to wordpress plugin

    Reply
  6. Pankaj says

    March 27, 2014 at 7:25 am

    This step by step tutorial for setting up google analytics is very helpful for newbies. You also included images for the ease of your audience. Great work Nile.

    Reply
  7. Matt says

    May 5, 2014 at 9:32 am

    Nice tutorial. I also don’t know that there is plugin for google analytics but I still prefer to place the code manually. Nonetheless, the guide is very easy to understand for newbies like me.

    Reply
  8. Scofield says

    May 31, 2014 at 4:51 pm

    i am planning to convert to wordpress and still confusing, your blog is veru useful and it will help me a lot in managing wordpress here is mine

    Reply

Leave a Reply Cancel reply

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

Primary Sidebar

Follow Me On:

  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!




Try to be More Positive on Social Media

Note: You can click on image and view the video in a larger lightbox window.

Footer

The Blog

Lots of free information, tutorials, and more to help you bring your best foot forward with your website.

  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!

Copyright © 2025 · · WordPress