Google Analytics is an indispensable tool in any webmaster’s arsenal. Some of the most important insights that you can gain from Analytics include: incoming searches, most viewed pages, how long people spend on your site, number of pages they view, and more. That’s why it’s important that you link your site with Analytics.
So, before we talk about anything, if you don’t have an Analytics account, create one now.
The best way to link Analytics with your site is by using Google Analytics for WordPress plugin by Yoast. This plugin not only inserts Analytics’ code in a proper manner, but it can also accommodate your tracking needs as your site grows and you require more data in your reports. That’s why I consider this to be an essential tool for any WordPress user.
Install Google Analytics for WordPress, and let’s talk about how to best configure it.
Go to the plugin’s admin page and click the authenticate with Google button. You’ll be taken to Google.com, click “Grant access” and you’ll taken back to your admin screen and will be ready to start using the plugin.

Select the correct profile from the drop-down list.
Google Analytics for WordPress default settings are suitable for most sites, but there are a few things that we wanna make sure are checked.
Checkmark “Track outbound clicks & downloads” and “Show advanced settings.” This way Analytics will report how many people click on your outbound links. Don’t press “Update Google Analytics Settings ยป” just yet.

Skip the “Custom Variables Settings” (unless you know how to use them).
In “Advanced Settings”, the first option is the “Ignore users.” Most people ignore “Administrator” because they don’t wanna track themselves. But if you don’t wanna track yourself, I’ll share with you a more reliable way to do it later on. Anyway, select the group that you wanna ignore and let’s move on.

I recommend that you check “Track outbound clicks as pageviews” and “Track downloads as pageviews.” Note that this will inflate your total pageviews but in return it’ll give you more data and therefore more insight into your outbound clicks and downloads.

For “Prefix to use in Analytics before the tracked pageviews”, I put /o/ — it’s the shortest prefix I could think of while staying relevant.
Make sure “Track the complete URL” is selected. Or else if you link to a specific page, say http://en.wikipedia.org/wiki/Wordpress, your Analytics report will only show “wikipedia.org”. So, you won’t know which Wikipedia page exactly the outbound click went to.

There are several other settings in the “Advanced Settings” section of this plugin, but I won’t go into what they do or how to use them because I don’t use them and I’m not sure what they do. ![]()
So, scroll down in your plugin’s admin page to the part that I do know, “Internal Links to Track as Outbound.” This feature is very helpful for tracking affiliate link redirects.
As you saw earlier, GAW can track outbound links by examining all links on your page. If it sees that you’re linking to a domain other than your own, it tracks it. But with the internal tracking feature, you can tell it: even a link that appears to be pointing to my own domain, I want you to track it if it begins with /out/, /recommends/, or /visit/, etc…
You also need to label those links with something so that you can distinguish them in your Analytics reports — “aff” is a good idea for a label.

That’s all. Now click any of the blue “Update Google Analytics Settings” buttons.
Bonus Tip #1: Filter Yourself Out of Google Analytics Reports
As you saw earlier, GAW allows you to ignore administrators, so that you don’t track yourself when you’re visiting your own website. While this feature helps, it’s not very reliable because you’ll almost certainly visit your site repeatedly from other browsers on which you won’t be logged in. So, here’s a good way to handle this situation.
Google Analytics itself allows you to filter out results based on criteria that you specify. You can tell Google Analytics to ignore all hits from a certain IP or IP range. That’s how I get it to ignore me and everyone else on my network. You can do the same.
Go to your Google Analytics settings page and find “Filter Manager” near the bottom right. In the “Filter Manager” page, find “Add Filter” and you’ll arrive on this page:

Name your filter something like “Exclude me”. Choose “Custom filter” and “Exclude”. For “Filter Field” select “Visitor IP Address”. Now you have to enter the “Filter Pattern” which is RegEx
.
My IP is ^87\.200\.51\.([1-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$. It looks scary, but all you have to do is replace 87, 200, and 51 from my pattern with the first three blocks from your own IP respectively. The last block is the range, and it’s handled by RegEx. I think I got this pattern from here.
Then “Add” your site to “Selected Website Profiles” and “Save Changes.”

Bonus Tip #2: GAW is the Best Way to Track 404 Errors
Google Analytics for WordPress is the best way to track 404 (Not Found) errors in your WordPress sites. Every time a visitor lands on a broken URL on your site, GAW will make Analytics report it.

More details on how to set this up here.
And checkout these links for more essential WordPress optimization and configuration tips:
Hi,
Where are the outbound links displayed on Google Analytics if you haven’t set the option to track them as page views on?
Thanks!
They’d be under “Events.”
can u plz suggest a plugin that can automatically ban ip address if the site/blog gets more than x no of click in a given period of time or if an ip address visits too often. but before the ip is blocked i want to set the above statistics.
Hey, Sorry, I don’t really know a plugin such as what you describe!