Tutorial: Add Google Analytics To WordPress Website

Google Analytics is a powerful free tool that allows you to track visitors to your website. In this article, we tell you everything about Google Analytics: how do you implement it on your WordPress website and what is possible?

What is Google Analytics?

Google Analytics is a free tool from Google that allows you to keep track of how many visitors come to your website and which pages these visitors view. You can use Google Analytics if you have a Google account (with which you also log in to Gmail).

To learn more about what you can “track” with Google Analytics, check out:  Google Analytics: the basics.

Implement Google Analytics in WordPress

To get Google Analytics running on your WordPress website, you can follow the steps below. You do need a Google account to do this. Don’t you have these yet? Then create it for free via Google Accounts.

1. Create a Google Analytics Property:

If you have a Google account, log in to Google Analytics. You will now enter a screen where you can set up your new Google Analytics account. Enter the required data (click on the image for a larger image).

It is important that you enter the URL of your website correctly. Also, make sure to select HTTPS if your website has an SSL certificate. You then set the extent to which the data from your Google Analytics property may be shared with third parties. I always uncheck all of them (click on the image for a larger image), because this is more favorable with regard to the cookie law (more about that later in this article).

Then click on Get Tracking ID (the blue button at the bottom). You will then first be asked to agree to Google’s terms. Choose the “United States” and click on “ I accept ”. You will now see a new screen with the tracking code.

2. Retrieve the Tracking Code:

Google Analytics now gives you a tracking code for your WordPress website:

Depending on how you are going to add Google Analytics to your WordPress website, you will need this tracking code (or at least the “Tracking ID” (the code that starts with UA ). Copy your tracking code and save it for the next step, or keep the window with the tracking code open in a separate tab.

3. Add Tracking Code to WordPress:

There are several ways to add this tracking code to your WordPress website. The easiest way is to install a plugin such as the MonsterInsights plugin or Google Analytics Dashboard for WP (GADWP). I prefer to use the latter myself. Both plugins can do about the same amount, but with MonsterInsights you need the (paid) “Pro” version and with GADWP all this is largely free.

Both plugins have a very handy feature: you do not have to enter the tracking code manually. You can log in to Google Analytics directly from your WordPress admin. The plugin then does the rest of the work. So make sure you install the plugin, activate it and select the correct property. In the case of GADWP, first, click on Authorize plugin:

If you then log in to Google, GADWP will automatically select the correct property based on the URL you entered in Google Analytics. Make sure you save the settings.

4. Testing:

Then, of course, you want to test whether the Google Analytics tracking works. For this we use the Real-time function of Google Analytics. Go to Google Analytics and select the correct property (which we have just created).

Now click on “REALTIME” in the bar on the left and then “Overview” (see also the image on the right). You will now see a screen that looks something like this (click on the image for larger):

Now navigate to your website and check whether the “0” in Real-time Analytics changes to a “1”. If so, your tracking code will work. You can now click around on your website and check whether Google Analytics sees all page views properly. You see this because blue stripes are visible in the “per second” overview on the right:

Pageviews per minute and per second

Now that you know that your tracking code is working properly, you can continue to set the plugin.

5. GADWP Plugin Settings:

When you click on “Backend settings” in the Google Analytics menu in WordPress, you will enter the following screen:

Here you can set which users in WordPress can view the statistics. The “Dashboard widget” must be enabled for this.

Dashboard Widget:

Users with the correct role then get a Dashboard widget in WordPress with statistics:

I have disabled this myself because I prefer to view the statistics in Google Analytics itself. So if you like it you can see your stats directly from WordPress. You can also enable reports so that you can immediately see in the WordPress admin how often a page is visited.

Under “Frontend settings” you can also set your statistics to be displayed on the front of your website (but only to logged-in users).


Under the menu “Tracking code” you will find all kinds of advanced settings. For example, under “Event tracking” you can send “events” to Google Analytics. We use this to track clicks to external websites and downloads:

The events that you can track are sent to Google Analytics and can be found in Google Analytics under “Behavior> Events”. These events are also available in real-time.

Our affiliate links start with / ga /, (for example, a link to Elegant Themes ), so the plugin knows thanks to the settings that it must be tracked as an outgoing link.

Exclude Tracking:

You can also exclude tracking for logged in users with GADWP:

By checking this for all types of users, you ensure that your own page views are not counted in the reports within Google Analytics.

Google Analytics: the Basis:

You can see a lot of different things in Google Analytics. This way you can see how many users have visited your website per day (and even per hour). In addition, Google Analytics provides information about how your visitors end up on your website.

Sessions, Users, and Page Views:

The most important statistics in Google Analytics are sessions, users and page views (page views). Sessions are the number of visits. These are not unique visitors, but purely how often your website has been visited. If you view your website twice in one day (once in the morning and once in the afternoon), that means two sessions from one user.

Users are the number of unique users that have visited your website in the period you selected. This number is therefore never higher than the number of sessions. If someone asks how many unique visitors you have, it is best to look at users.

Pageviews (known as page views in English ) mean how often pages are viewed. If you view one page and click “refresh” five times, then those are five page views.

Pages Per Session and Bounce Rate:

Also important is the number of pages per session. This is the average number of page views (page views) per session. The bounce rate stands for the number of visitors who only view one page and then leave your website.

Target Audience:

Under Target group you can see everything about your visitors; from which country (and even city) do they come, which device do they use and much more. The image below ( these are not the Analytics of Wiki Soft YT) shows this well: visitors from the Netherlands and Belgium view more pages on a Dutch website than visitors from the US, Brazil, and Spain. Click on the image for a larger view.

Overview by country in Google Analytics (click for larger)


Under the tab ” Acquisition ” you can see where your visitors come from. The most important four sources are:

  • Organic Search
  • Straight away
  • Social
  • Referral

Organic Search is the number of visitors from search engines such as Google. Immediately stands for visitors who “directly” came to your website (no source was detected). Social provides information about visitors from social media and referrals are visitors who came to your site via another website (for example via a hyperlink).

Real Time:

A nice feature of Google Analytics is “Real-time”. Here you can see how many visitors there are on your website, where they come from and what pages they are viewing.

Real-time is especially nice if you have a website with a lot of visitors. It gives a lot of people a kick when you see that there are 20 or 30 visitors on your website at the same time. In addition, real-time is very useful to test whether your tracking code works properly; after all, you can immediately see whether page views (page views) are coming in properly.

Real-Time in Google Analytics (click for larger) – screenshot of our own Analytics

Cookie Act: No Permission Required?

Google Analytics uses cookies to collect information about your visitors. For example, a cookie is placed to recognize whether someone visits your website for the first time (or whether it is a “returning visitor”).

If you arrange a number of things well, you do not have to ask your visitors for permission to use Google Analytics (source: Comaxx ). Take good care of the following:

Do Not Include IP Addresses:

Under the advanced settings of the GADWP plugin you can choose to make IP addresses anonymous:

Make sure that you have this setting set to “On” so that the IP address of your visitors is not shared with Google.

Turn Off Data Sharing:

You did this in step 1. You can adjust this at a later time via the settings in Google Analytics. You can get here as follows:

Uncheck all options so that no data is shared with Google and/or third parties.

Inform Your Visitor About Analytics:

Make sure that the privacy statement of your WordPress site clearly states that you are using Google Analytics. Also, explain what Google Analytics does and what you use it for. It can also be helpful to explain what measures you have taken to protect your visitor’s privacy. For example, IP addresses are not sent to Google.

Use and Force SSL:

Finally, make sure that your website has an SSL certificate. This ensures that your website is only accessible via HTTPS. This way the data of your visitors is extra well protected. An SSL certificate is nowadays free in many cases. At iXL Hosting, you can use a free certificate from Let’s Encrypt.

Google Analytics: Advanced:

We previously showed the basic statistics that you can obtain about your visitors in Google Analytics. Now it is time for some examples of advanced information that you can gather by using, for example, Custom dimensions.

Custom Dimensions: Author and Category Statistics:

With custom dimensions, you can see nice information in Google Analytics. In the GADWP plugin, you can add certain custom dimensions for free. These are especially useful for (large) blogs with, for example, different categories and multiple authors.

For example, we can see per author how many page views this author has had (click on the image for larger):

This can be very useful for several reasons, such as distributing blog earnings by author. You can set this as follows:

1. Settings in Google Analytics:

In Google Analytics you choose “Administration”, “Custom definitions” and then “Custom dimensions”. You will now see the following screen:

We have three custom dimensions: author, year of publication and category. When you click on the red button (“New custom dimension”) you will see the following screen:

Choose a name (for example “Author”), select “Hit” and make sure that the setting “active” is checked. Then click on “Save”. Do the same for category and publication year, for example.

2. Setup in the GADWP plugin:

Now go to the menu in WordPress: Google Analytics> Tracking code and choose Custom definitions.

You have to choose a number per dimension. This corresponds to the number that you see in Google Analytics (see also the previous step) under “Index”.

Now click on save in the GADWP plugin and from now on the custom dimensions will be kept. You can also do this for publication month, tags, and user type. However, we find the author, the year of publication and the category especially important and interesting.

3. See Custom Dimensions in Google Analytics?

But where can you find these statistics in Google Analytics? By default, you will unfortunately not see this data anywhere in Google Analytics, but it is there! However, you must create a Custom Report for this. This sounds complicated, but it is actually very easy.

In the image on the right, you can see where you can create these customized reports. You do this under Customization and then Custom Reports.

Now click on “New custom report” and give it a name. You then choose one or more statistic groups. We find the following statistics especially important:

  • Pageviews
  • Conversion rate
  • Bounceratio

You select these groups as follows:

After you have added all the groups that you find interesting, choose the custom dimension under Dimension Details. You just created it (in step 1) yourself:

Then click on save and the report will now be visible with the modified reports in Google Analytics. For example, this report might look like this (test data from our custom dimension for categories):


I already showed a screenshot with the GADWP settings: you can also track “events” on your WordPress website. These can be all kinds of things: a (PDF) download, clicking an outgoing link or clicking an affiliate link.

Because the revenue model of many blogs – including Wiki Soft – largely revolves around affiliate links, we also track visitor clicks to websites such as Elegant Themes.

You can find these events in Google Analytics under Behavior> Events> Overview.


Do you have a webshop? Then, of course, you want to track the conversion in Google Analytics. You can choose to use eCommerce tracking. This is also standard in the GADWP plugin. This form of tracking has been expanded to such an extent that it may be worthy of its own article. For now, I advise you to read this article by Blok Webdesign.

Other examples where you can track the conversion are:

  • Forms
  • Outgoing (affiliate) clicks

Track Outgoing Clicks as Conversion:

Tracking outbound clicks as a conversion is actually a combination between tracking “Events” and setting a “Target” in Google Analytics. As I just explained, the GADWP plugin can automatically track outbound clicks as an event. Internal links can also be set as an outgoing link. This is useful for affiliate links such as our affiliate link: www.yoursite.com/ga/elegant-themes/. You can “attach” a conversion to this in Google Analytics as follows: go to Administrator and then Goals.

Create a new goal and choose “Custom” (or “Custom”) under Target configuration. Under Target description you choose a name and type. The type, in this case, is an “Event”. Under Goal details, you can now specify the event conditions that trigger a conversion (or “goal accomplished”). In our case, that is when the Event Label starts with “www.yoursite.com/ga/elegant-themes”.

Then choose to save. From this moment on, the conversion for this “Goal” will be measured.

Track Other Ways of Conversion:

There are several ways to create a goal in Google Analytics. This way you can also set a specific page as a goal. For example, if you have a contact form with a “Thanks” page, you can set the URL of that page as a conversion target.

Connect Google Analytics to Google Search Console:

In Google Analytics you can see where your visitors come from under Acquisition. However, little is clear about the search terms used for this. These are often on “Not provided”. To obtain more information, you can link your Google Analytics property to your WordPress website in Google Search Console (formerly: Google Webmaster Tools).

You can make the link by going to the Search Console tab in Google Analytics under Acquisition (see image on the right).

Additional Tips:

Extra tips that you can use to find out specific information about your WordPress website with Google Analytics.

Add Users to Google Analytics:

Do you want to give others access to your Google Analytics account? You don’t have to give them your Google password, but you can share your Google Analytics property with these people. They can then log in again via google.com/analytics and see your WordPress website automatically.

For this, you need the email address that they use for their Google account. You can add this under Administrator> User Management. You will then see the following screen:

Enter the e-mail address and choose the rights you want to give someone on the right. If you only want to share the statistics, choose “ Read and analyze ”. You can optionally choose to inform the new user by e-mail. The person will then receive an email from Google Analytics to let them know that they have gained access to your property.

Badly Performing Pages:

One of the things I would like to know for our blog Wiki Soft YT is: which URLs are performing poorly? By that, I mean: which URLs get fewer visitors than I would like?

To find out, in Google Analytics, go to Behavior> Site Content> All Pages. Then I select a long period in the top right corner, for example, a year:

After clicking on “Apply” you will get a list of all pages that have been visited at least once in the past year. However, there are also a lot of pages that are often visited. To filter it out, we will create a filter. Click on “Advanced” next to the search field and fill in a filter as follows:

Then click “Apply” and you will only see the pages that have had less than 100 page views in the past year.

Filter Out Irrelevant Pages:

You do not want to see certain pages here, for example archives that end with / page / 7 / or / page / 8 / . We filter these out with a second filter:

Note: this filter must be set to “ Exclude ”. You can add even more filters to exclude more types of pages. For Wiki Soft YT I have now found 1029 pages that have had fewer than 100 page views in the past year.

This is very valuable information because I also see articles in it that used to perform really well. I can now put it on my list to rewrite or update it. Updating or rewriting old articles is very useful; Google will see your page as “fresh content” and therefore rank better in the search results.

Navigation Overview:

With the “Navigation overview” function you get information about how people ended up on a specific page. This only concerns visitors who came to the same website from other pages.

Select a page via Behavior> Site content> All pages and now click on the tab Navigation overview at the top. The example below shows what this looks like for our page “ What is WordPress? ”(Click on the picture for a larger version)

We can see that most visitors to this page come from the / beginners/page and also most visitors go there from this page. Very useful information!

UTM Tags:

A handy tip about which you can also read more on the blog of Karel Geenen; creating special campaign URLs. These are URLs that you can then share on, for example, Facebook. Thanks to these URLs, Google Analytics will track the visitor as a visitor coming in from a “campaign”, no matter how that visitor arrives.

To create such a special URL you can use the Campaign URL Builder. Tools such as Mailchimp also offer you the option to automatically convert links in your newsletter to special campaign URLs.


One useful way to find more relevant information in Google Analytics is to use segments. You can then filter data so that you only see relevant information. For example, segments allow you to filter out visitors from certain countries or visitors who come to your site from certain other websites ( SPAM referrals, for example ).

The above image shows the standard segments in Google Analytics. You can also create a segment yourself based on all kinds of filters. One handy standard filter is “Converters”. You will then only see information about the visitors who have led to a conversion. This way you can find out how these visitors behave and then respond to this again.

The Search Function on Your Website:

Do you use a search function on your WordPress website? Then, of course, you want to know what your visitors are looking for! Go to Administration> View Settings  (under “View”). Now scroll to Site Search and turn it on. Now enter “s” in the field:

Google Analytics will now automatically recognize when someone places a search query on your WordPress website. This is because every URL of a WordPress search starts with “? S = “, for example: search query . Now go to Behavior> Searches on the site and you will see what your visitors are looking for:


Is your website responsive? When you look at Target group> Mobile in Google Analytics you will see how many visitors visit your WordPress website with a smartphone or tablet. On Wiki Soft YT, 85% of visitors still come from desktop computers, but on many other websites that are very different.

Is your website not mobile-friendly and do you have relatively many visitors to “mobile”? Then it’s time to start using a responsive WordPress theme! Fortunately, almost all themes are responsive nowadays. An additional advantage is that Google rewards mobile-friendly websites.

Visitors Per City:

Via Target group> Geo> Location you can see not only from which countries your visitors come, but also from which cities. Wiki Soft YT is the most visited in Amsterdam, followed by Rotterdam.

However, the ratio is not in line with the difference in inhabitants between the two cities; almost 10 percent of our visitors come from the capital, and less than four percent come from Rotterdam.

In addition to location, you can also filter by province and in some countries (such as the US) also by “Metropolitan Area”, for example, “Boston MA-Manchester NH” (a metropolitan area divided into two states).