Featured templates

How to install Google Analytics on WordPress

Ammy Brown February 28, 2018
Rating: 5.0. From 1 vote.
Please wait...

Starting your website you could have three crucial questions:

  1. Who is visiting your site?

  2. What posts are the most popular?

  3. And how people interact with your site?

We are going to show you how to gather that information in this tutorial. To get that info, you can use Google Analytics. There are different ways to use Google Analytics on your website. We will discuss them further.

How to get Google Analytics code?

  1. The first step is Google Analytics account setup. Please, visit Google Analytics Signup page. If you already have Gmail account, you can use it to sign in.

  2. You will see the following page on your screen. Click on Sign Up button.

  3. Now you can proceed to the next step. Click Website tab on the page you see and start entering your account information:

    • Account Name;

    • Website Name;

    • Website URL;

  4. Once you are ready, click on the Get Tracking ID button to get Google Analytics tracking code. You will see the ‘Terms and conditions’ pop-up, click on the I Agree button to be able to get the code.

  5. You can see Google Analytics code now. Copy it to paste it into your website. You can leave this page opened to be able to get this code easily.

How to insert Google Analytics code?

We already mentioned that there are several ways to add Google Analytics Tracking code to WordPress website. So what are they?

  1. Using MonsterInsights plugin.

    • To install MonsterInsights plugin, log into your WordPress admin panel, and navigate to Plugins > Add New section. Enter Google Analytics by MonsterInsights into the search field.

    • Install and activate the plugin.

    • Navigate to Insights > Dashboard section in your backend and authenticate your website with Google Analytics by clicking the Authenticate with your Google account button.

    • Click To Get Google Code button in the pop-up. Give MonsterInsights access to your Google Analytics data by clicking Allow. Copy the code and switch to your application to paste it.

    • Select your account from Select the Google Analytics Profile to Use drop-down and click the Close button.

    • Now, visit Insights > Dashboard to see Google Analytics data. You may need to wait up to 24 hours to get data populated there.

  2. Using Insert Headers and Footers Plugin plugin.

    • Open the Plugins > Add New page and search for the Insert Headers and Footers Plugin. Install and activate it.

    • Navigate to Settings > Insert Headers and Footers page.

    • Here you need to paste Google Analytics code into the header or footer box.

    • Click ‘Save’ to save the changes.

  3. Insert Google Analytics tracking code to the theme files. You can do that in case you don’t want to use additional plugins or if you’re familiar with the code. There are 2 ways to add code:

    • Simply edit the header.php file under Appearance > Editor section in your WordPress dashboard.

      Enter the code just after the <body> tag and click on the Update file button to save the changes.

    • Or you can modify theme functions.php file. You can access it from the same Editor page. Use following function to add Google Analytics tracking code:

          add_action('wp_head', 'wpb_add_googleanalytics');
          function wpb_add_googleanalytics() {?>
          // Paste your Google Analytics code 
        <?php } ?>

      Where // Paste your Google Analytics code is your Google Analytics code.

That is it! You know how to install Google Analytics on WordPress now.

We would also suggest you to check out the latest collection of WordPress themes to build your very own website.

Best Responsive Wordpress Themes
This entry was posted in Monstroid Tutorials, WordPress Tutorials and tagged Google Analytics, tracking. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket