How to install Google Analytics

Last updated: · By · Google Tutorials · No comments yet
How to install Google Analytics?

Google Analytics is a very powerful tool to monitor your website’s performance. It is completely free, and installing it doesn’t require any special knowledge. In this post I’m going to show you how to install Google Analytics step by step by step on your website or blog.

Get a free Google Account

I think everyone has a Google account (eg for Gmail), but if for any reason you don’t, just register a Gmail account or go to the Google Analytics Website and click “Create an account” and follow the simple steps.

Sign in to you Google Analytics account

Following the link to the Google Analytics website, you can sign in with your existing Google account. Click “Sign in” in the upper right corner and use your Google credentials.

Google Analytics login screen

Once you’re signed into your Google Analytics account, click on Admin at the upper right corner then create a new account. This is not the same as your Google account, it’s an Analytics account to keep track of one or more websites. Also you can share your data with specific users later within one account.

The process is very straightforward here, and I’d like to show you more about how to actually use your Analytics account. At the time of publishing this post, I recommend you choose the Classic Analytics settings. Name your property, enter your url, provide your industry and timezone. Now click on Get Tracking ID and you’re good to go on the Google side.

Google Analytics create property

How to Install Google Analytics tracking ID

Now you’ve been redirected to a page where you can see your new Google Analytics tracking ID. This looks like UA-XXXXXXX-YY, where XXXXXXX is your account’s ID, and YY is the ID of your property (or website).

Your Google Analytics tracking ID is not something that works by itself. It needs to be installed (or better said embedded) in every single page of your website that you want to track. This way when someone visits one of your pages, the Analytics code gets “activated” so Google can keep track of your visitors.

You have several different ways to install this ID on you website in order to Google keep track of every occasion when someone visits your site.

Recommended for WordPress users: the Google Analytics plugin

I’m not a huge fan of using plugins for every task in WordPress. Also installing your Analytics ID manually is not a big deal, all the same I recommend you using a specific plugin this time.

Download and install Google Analytics for WordPress plugin to your site. Other than tracking your visitors you can set up a ton of other useful things. These may not be that important when you just start a site, but you’ll find out how valuable they are later. Just to name a few, you can track your outbound clicks easily, track which categories or authors are the most prosperous and you can easily ignore users like administrators so checking your site 50 times a day won’t mean you 50 extra visits. For me these additional features are worth the pain of having another plugin installed.

Short side note: somehow the verification in this plugin is never working for me. Just go to Settings » Google Analytics, check Manually enter your UA code and enter the code you received from GA.

Setting up inside your theme

Sometimes your theme provides an option of entering your tracking code. It’s as easy as is, simply enter the whole tracking code (with the script part), hit OK and you’re good to go. It’s all the same except that you’ll lose the extra functionality of the Yoast plugin.

Manually in the code

You can also edit your code and embed the GA tracking code. For this you need to edit your header section, right before the /head tag in your html – that’s usually in header.php in WordPress. Simply copy-paste the whole code just before the closing head tag, it will look someting like this:

Please note that if you are not maintaining your own theme, after the next plugin update this change won’t take any effect, you’ll need to reenter your code.

Also if by any reason (eg for a squeeze page) your theme uses different header files, you have to enter your code in each one of them. A better solution might be to create a function to add you GA code, and add this to the wp_head hook as follows. You can place this in functions.php


Whichever option you choose, be sure to only use your GA code once in your site.

How to check if your tracking ID is installed properly

Once you’re done, you can check if the Google Analytics code is printed out to your website. Load your homepage or any other page (be sure to log out of WordPress if you’ve set up ignoring WordPress users in the Yoast plugin previously), then click Ctrl+U which will bring up your page’s source.

Hit Ctrl+F for search, and enter “var ga“. If you find this string, and you see the whole tracking code, than it should work.

Also if you go back to your Analytics dashboard, in the Admin section select “Tracking Info” under your property, you should see Status: Tracking Installed above your tracking ID.

Google Analytics Tracking Code Installed

Google Analytics Tracking Code Installed

Your opinion is important. Please tell us what You think!

No comments yet. Tell us your opinion!