Install Google Analytics on your WordPress site

How to Install Google Analytics in WordPress

There are many different ways to setup Google Analytics in WordPress. We will show you three different methods where the first option is the easiest and the last being the hardest.

You can choose the one that best suits your needs.

1. Google Analytics for WordPress by MonsterInsights

MonsterInsights is the most popular Google Analytics plugin for WordPress. Over 1 million websites use it including the likes of Bloomberg, PlayStation, Zillow, and more.

It is the easiest and by far the best way to add Google Analytics to WordPress (for all users beginners and experts).

MonsterInsights has both a free version and the Pro version. In this tutorial, we will be using the MonsterInsights free version.

You can use the MonsterInsights Pro version if you want more advanced features like Ecommerce tracking, Ads tracking, Author tracking, etc. The process of setting them up is the same.

Let’s get started.

The first thing you need to do is install and activate the MonsterInsights plugin.

For more details, and if you want to learn how to install and manage WordPress plugins, see our WordPress basics course.

Upon activation the plugin will add a new menu item labeled ‘Insights’ to your WordPress admin menu. You need to visit Insights » Settings to configure the plugin settings.

On this screen, you need to click on ‘Authenticate with your Google account’ button to connect Google Analytics with your WordPress site.

authenticate WP

This will bring up a popup where you will be able to authenticate with your Google Account.

authenticate Google

Click on ‘Next’ to continue.

Now you need to click on ‘Click to get Google code’ button.

Get authentication code

This will bring up another popup with the message ‘MonsterInsights would like access to your Google Analytics data’.

Click on the ‘Allow’ button to continue.


The authentication popup will now show you a line of code which you need to copy.

authentication code

Next, you need to enter this code in the MonsterInsights popup and then click on ‘Next’ to continue.

enter google code

The final step is to select the profile you want to track. You need to select your website here and then click on the next button to continue.

select google pofile

That’s all you have successfully installed and setup Google Analytics on your WordPress site.

Remember, it will take Google Analytics sometime before showing your stats.

The best part about MonsterInsights is that you can view your Google Analytics report inside your WordPress dashboard. Simply visit Insights » Reports page to checkout a quick overview of your analytics data.


You can go also go in the Tracking tab to customize the tracking settings based on your needs:

insights tracking

Note: MonsterInsights was formerly known as Google Analytics for WordPress by Yoast.

2. Insert Headers and Footers Plugin

This method is not as not as good as MonsterInsights because you will not be able to do advanced tracking configuration, and you will not be able to view Google Analytics data in your WordPress dashboard.

First, you need to install and activate the Insert Headers and Footers plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings » Insert Headers and Footers page. Here you need to paste the Google Analytics code that you copied in step 4 into the headers section.

adding code to header footer in wrdpress
Don’t forget to click on the save changes button to store your settings.

3. Install Google Analytics in WordPress Theme

This method is for advanced users only who are familiar with code. It is somewhat unreliable because your code will disappear if you switch or update the theme. We almost never recommend using this method.

If this is your first time adding code to your WordPress files, then you should check out our guide on how to copy paste code snippets in WordPress.

Add code in header.php file

Simply edit the header.php file in your WordPress theme and paste the code you copied in step 4 right after the <body> tag.

Don’t forget to save your changes and upload the file back to your server.

Add via Functions File

You can also add Google Analytics tracking code to WordPress functions file. It will then automatically add code to every page on your WordPress site.

You will need to add this code to your theme’s functions.php file.

1 <?php
2 add_action('wp_head', 'wpb_add_googleanalytics');
3 function wpb_add_googleanalytics() { ?>
5 // Paste your Google Analytics code from Step 4 here
7 <?php } ?>

Viewing Reports on Google Analytics Website

Google Analytics is capable of showing you a treasure of data collected from your stats. You can view this data by visiting your Google Analytics dashboard and clicking on the reporting tab.

Google Analytics reports

You will see the built-in Google Analytics reports in the left column. Each section is divided into different tabs and clicking on a tab will expand it to show more options.

  • Audience tab will show reports to help you understand your users.
  • Acquisition reports explore where your users came from.
  • Behavior reports summarize what your users do after they arrive on your site.
  • Conversion reports show how well you’re doing against your goals.

We hope this article helped you learn how to install Google Analytics in WordPress.

Add new Posts through Email

Add a new Post by Email

Post by Email is a way of publishing posts on your blog using your email. Any email client can be used to send the email, allowing you to publish quickly and easily from devices such as cell phones if you don’t have the WordPress mobile app installed.

The internal WordPress ‘post by email’ has been disabled and will be removed from WordPress. It is recommended to add this useful functionality by installing the widely used Jet pack plugin.

Once Jet pack installed and activated, you need to switch on the Post by Email module:

You can do this in a few easy steps:

  1. Go to Jetpack > Settings > Writing in your dashboard, and open the Post By Email card.
  2. Click on the toggle to activate the module.
  3. Copy the special email address that was generated for you.

Need more detail? Read on or click directly to the section you want to see.

Sending Emails

Once you have your Post by Email address, sending an email is simple:

Post By Email - mail example

The email subject is used as your post’s title. The body is the post’s contents. Please note you can only post to one recipient at a time.

Mail Formatting

Your email can be plain text or formatted. As much formatting as possible will be retained, although the Post by Email system will strip unnecessary HTML tags so that your email is displayed correctly. Note that you will need to use an email client that supports rich text or HTML formatting in order to make use of this feature. Most website based clients (Hotmail, Gmail) do support this, as do most desktop clients (Outlook, Mail). You may need to switch your client into rich text or formatted mode.


Post by email will automatically remove any email signatures that match the standard signature block pattern:


(that is, dash dash space)

It will also remove anything after a <hr/> HTML tag and attempts to clean up cellphone network signatures.

If your email system attaches a signature that does not match any of these patterns then you can manually tell Post by Email to stop including text by adding the special [end] shortcode on its own line with a blank line above it. Anything after this will be removed from your post. If your cellphone network is adding a signature and you want us to remove it, then let us know the details and we’ll look into it.


Image attachments will be included in your published post as follows:

  • Single images will be displayed inline (a single image is defined as an image without an image immediately following it).
  • Multiple images will be displayed as a gallery.

Multiple galleries and single images are allowed in the same post. Note that using the [nogallery] shortcode will disable all galleries.


Special shortcodes can be embedded in your email to configure various aspects of the published post:

  • [category x,y,z]
  • [excerpt]some excerpt[/excerpt]
  • [tags x,y,z]
  • [delay +1 hour]
  • [comments on | off]
  • [status publish | pending | draft | private]
  • [slug some-url-name]
  • [title Your post title]
  • [end] – everything after this shortcode is ignored (i.e. signatures). Make sure it’s on its own line with a blank line above it.
  • This slideshow requires JavaScript.

     – replaces the auto-gallery with a slideshow
  • [nogallery] – disables the auto-gallery and displays all images inline
  • [more] – more tag
  • [nextpage] – pagination
  • [publicize off|yahoo|twitter|facebook] – change Publicize options (see below)
  • [poll]question and answers[/poll] – insert a Polldaddy poll into your post (see below)

Shortcodes can be included anywhere in the body of your email and must be in lowercase. There should be no spaces between the left square braket and the shortcode content.

Specifying the Category

The category shortcode will match the category-slug specified. For example:

[category holidays,main-dishes]

Will match the categories “Holiday” (slug=holidays) and “Main Dishes” (slug=”main-dishes”). Note that categories must already exist on your blog for you to use the slug. If you want to add a new category, just type the new category name in the shortcode along with any other category-slugs. Spaces between the commas are not important.

Specifying Tags

Any number of tags can be added to your post, each separated by a comma:

[tags one potato, two potato, three potato, more]

This will add four tags: “one potato”, “two potato”, “three potato”, and “more”. Note that your tags do not need to exist elsewhere in your blog and new tags will be created automatically.

Changing your Publicize settings

Jetpack’s Publicize lets you notify other web services about your posts. With the [publicize] shortcode you can control this from emails. Note that your Publicize settings must have been previously configured for these shortcodes to work. Also, if you have already configured Publicize and don’t include these shortcodes in your post, it will be Publicized to all of your connected Publicize networks.

[publicize off] – disable all Publicize notifications

[publicize twitter] – only send a notification to Twitter

[publicize twitter]my new post[/publicize] – only send a notification to Twitter and set the Twitter status to my new post

[publicize twitter facebook] – Sends a notification specifically to both Facebook and Twitter only.

Note that if you use more than one [publicize] shortcode in your post (for example, both [publicize twitter] and [publicize facebook]), only the second shortcode will be used (in this case, [publicize facebook]). If you want to Publicize to only those two services such as in this example, you need to use a combined shortcode, like [publicize twitter facebook].

Inserting a Polldaddy poll

You must first have created or imported a Polldaddy account into before using this shortcode. Once setup you can insert a poll in an email as follows:


What is the worst movie of the decade?

* The Love Guru

* Fool’s Gold


Note how the poll question is added after the [poll] shortcode, and each answer is on a new line and starts with an asterisk. The poll must be finished with [/poll].

You can configure your poll by adding extra details to the [poll] shortcode:

  • type="single | multi | 2 | 3" – how many times a vote may be registered (single by default)
  • style="manga medium" – the style of the poll, as taken from the Polldaddy polls page.
  • other="yes | no" – allow an ‘other’ response (noby default)

For example, to create a poll with the wide ‘manga’ style and allow up to three responses (including an ‘other’ response):

[poll style="manga wide" other="yes" type="3"]

What is the worst movie of the decade?

* The Love Guru

* Fool’s Gold


Delaying Your Post

The delay shortcode will accept any time allowed by PHP’s strtotime. For example, you can:

[delay +1 hour]

[delay +2 days]

Providing a post title

The title of your published post is usually taken from the subject line of your email. In some instances, such as when sending an email from some cell phones or via a MMS-Email gateway, you may not be able to provide a subject. In this instance, you can set your post title directly inside the email:

[title My Fancy Post]

Changing your post status

Sometimes you may want your post to be private, or to be reviewed by yourself or someone else at a later date before being published. To do this, you can use the [status] shortcode to set the post status.

[status private]

Example Email with Shortcodes

The following email will be published in two days’ time to the “WordPress” category, with tags “announcement” and “WordPress”:

Welcome to Post by Email, the easiest way to blog!

[tags announcement, WordPress]

[category WordPress]

[delay +2 days]

Hello WordPress world!

Welcome to WordPress in Cyprus.

Discover a whole new world. Get your message on the Net with WordPress.

Easy. Fast. Fun.

Our WordPress classes in Cyprus help you getting it right and we teach you all you need to become WordPress proficient.

Publish your site in any language, Greek is no issue. Or make it multilingual (this is taught in our Advanced WordPress course).