Once you have created your site in WordPressWhether it is the classic "showcase site" (who we are, what we do, where we are), a Landing Page for the Lead Generation created with a Page Builder like Elementor, Divi, Beaver Builder or SeedProd or a ecommerce (perhaps created with WPEngine), it is right and proper thing connect Google Analytics to your WordPress site.
It is not necessary to go into the specifics of the importance of connecting Google Analytics (or its alternative) to your WordPress site, but suffice it to say that Google's Web Analytics platform, by monitoring activity on your website thanks to a snippet (fragment) of code inserted in the header of each page (and we'll see below how to do that), provides a large amount of data, which can be divided into 5 parts, basically corresponding to the various Google Analytics Reports:
- Real time: is a section that provides data on what happens in real time on the site
- Audience: who visits your site? The Public Report tells us, including demographic data
- Acquisition: where do visitors to your site come from? Organic traffic (SEO), Google ADS, social, referrals? The Acquisition Report goes into detail about this data with specific metrics.
- Behavior: what do visitors to your site do and how do its pages perform?
- Conversions: allows you, once you have set your goals, to track conversions and their sources of acquisition, whether it's leads or sales in theecommerce.
How to Add Google Analytics to WordPress (4 Methods)
Before we get into the details of how to connect WordPress and Google Analytics, you need to create a Google Analytics account.
Once created, you can move in 2 directions: add Google Analytics to WordPress "manually" or with a plugin. Before we see how to do either way, let's understand the pros and cons of the 2 approaches.
Without Plugin: pros and cons
- Pros: this is perhaps the best solution for those who "fiddle" and have more time: thanks to the insertion directly into the Theme or (better) through Google Manager you can make yourself independent from the addition of a plugin.
- Cons: in case of Theme change you have to remember to repeat the insertion in the code snippet. Creating custom dimensions, tracking events can be complex and time-consuming;
With Plugin: pros and cons
- Pros: this is perhaps the best solution for those who don't "tinker" or have little time or are not familiar with advanced configurations.
- Cons: Regarding the possible impact of the inclusion of a plugin on performance and loading times, the situation should be evaluated case by case, going first to understand how plugins can impact loading time and evaluate it with a plugin 😉 like P3 Plugin Performance Profiler.
Given the pros and cons, let's look at 4 alternatives, starting with the help of a plugin.
Google Analytics in WordPress with MonsterInsights
MonsterInsights (www.mosterinsights.com) is the most popular Google Analytics plugin for WordPress. It is used by more than 1 million websites, including Bloomberg, PlayStation, and others.
It's the easiest way to add Google Analytics to WordPress, for all users, beginners and experts alike: if the former can get rid of coding on the site and setting up some more complex tracements, the latter can save time.
MonsterInsights is available as both a paid premium plugin and a free version. In this tutorial, we will use the free version of MonsterInsights.
You can use the MonsterInsights Pro version if you want more advanced features like ecommerce tracking, ad tracking, author tracking, the setup process is the same.
Let's get started.
The first thing you need to do is install and activate the MonsterInsights plugin.
After activation, the plugin will add a new menu item called "Insights" to the WordPress admin menu.
Clicking it will bring up the MonsterInsights setup wizard.
First, you'll be asked to choose a category for your website (a business website, blog, or online store). Select one and click the "Save and Continue" button.
Next, you need to click the "Connect MonsterInsights" button.
You will see a popup that will take you to Google accounts where you will be asked to sign in or select a Google account if you are already signed in.
Next, you will be asked to allow MonsterInsights to access your Google Analytics account.
Click the "Allow" button to continue.
The final step is to select the profile you wish to monitor. You need to select your website here and then click the "Complete Connection" button to continue.
MonsterInsights will now install Google Analytics on your website. Next, you will be asked to select the recommended settings for your website.
The default settings would work for most websites. If you use an affiliate link plugin, you need to add the path you use to mask the affiliate links. This will allow you to track your affiliate links in Google Analytics.
Click the Save and Continue button to save your settings.
Next, MonsterInsights will show you the paid add-ons that you can access if you upgrade to PRO. You can simply click the "Save and Continue" button to skip this step.
Then you will be asked to install the plugin WPForms, (www.wpforms.com) one of the most popular WordPress contact form plugins. You can install it or just click "Skip this step"
This is all you have properly installed and configured Google Analytics on your WordPress site. Remember, Google Analytics will take a while before showing your stats.
The best part about MonsterInsights is that you can view Google Analytics reports in your WordPress dashboard.
Simply visit Insights " Reports to check a quick overview of the analysis data.
Note: MonsterInsights (www.mosterinsights.com) Was previously known as Google Analytics for WordPress by Yoast. WPBeginner founder Syed Balkhi acquired the plugin in 2016 and renamed it MonsterInsights. It is now part of our WordPress plugin lineup which also includes. OptinMonster, SeedProd, RafflePress.
Google Analytics in WordPress via Theme or GTM
If you don't want to use a plugin, it basically has 2 ways:
Paste GA Tracking Code before in Theme
Install the Google Analytics code in WordPress directly into your theme. Paste the Google Analytics Tracking Code (gtag.js, Global Site Tag) right before the closing tag in the header.php file. Tip? Use a child theme so that the tracking code is not overwritten every time you update your WordPress theme.
Paste GA Tracking Code via GTM
In this case you need to create an account on Google Tag Manager, configure Google Analytics from there and add the GTM code to WordPress (recommended). You can also do this via a plugin 😉 such as Header, Footer and Post Injections by Stefano Lissa, well done and...Made in Italy.