Are you ready to learn how to install Google Analytics in WordPress?
Do you want to know who visits your website, whether it’s a fashion blog, eCommerce store or a local business page?
It’s crucial data to have when you want to monetize your website or sell your products and services.
That’s where Google Analytics or GA comes in.
It’s one of the most popular analytical tools that generate and display all the necessary data you need for analyzing visitors’ structure.
The best thing is: It’s completely FREE TO USE.
This post covers:
- Why is Google Analytics important?
- How to set up Google Analytics (easy!)
- Add Google Analytics code with a WordPress plugin
- Best WordPress Google Analytics plugins
- Add Google Analytics code without a WordPress plugin
- FAQs about installing Google Analytics in WP
Why Is Google Analytics Important?
Let’s first dissect why you will use it in the first place.
Will you really just go to Google Analytics and check the number of visitors?
Maybe, if you just have your blog for fun.
But, you will want to dive much DEEPER into all the functions if you want to make any sort of income from it.
Even when you are using it for several years, there will still be many functions just hiding in plain sight.
(Or Google may add something new for us to benefit from.)
You will use GA to better understand:
- Who are your website visitors (gender, age, language, etc.)
- What they do & how long do they stay on your website
- How visitors find your website
- When do they visit your website
- Where do they come from (organic, direct, social)
But let’s set it up first before you can enjoy all the perks.
How to Set Up Google Analytics (Easy!)
Step 1: Sign up with Google Analytics
Visit the Google Analytics website and start the process.
It’s very simple and quick.
Click create an account and the page will guide you through the rest of the process.
If you already have a Google account use the sign-in option (which gives you INSTANT access).
After you sign in, a welcome screen will greet you and prompt you to start measuring.
Now it’s time to provide your account name.
I suggest you name it after your business or your website. This will help you keep your Google Analytics more organized, especially once you start adding more.
Don’t confuse yourself.
Step 2: Create a Google Analytics property
Create a Google Analytics 4 property to start measuring your website or app data.
An important thing to know here is that Google recently presented a new version called Google Analytics 4 or GA4.
You can now collect and measure data from both your website and app in the same place, which is a lot more hassle-free if you use both.
Proceed and set your business’s property name, time zone, and currency.
On the next screen, you will be prompted to fill in your business information.
Set your category, business size, and why you’re interested in using Google Analytics.
After you click the create button a popup window will appear and we all know what to do here.
Click agree and you are ready to roll!
Google Analytics will now take you on a short tour.
I RECOMMEND you go through it if you are not yet familiar with the website.
I did it, too!
It will help you grasp the basic elements of how everything works.
Step 3: Add your website to Google Analytics
Now that you are filled with new knowledge it’s time to add your website to the stream.
Since we are adding a stream for a website, click Web as a platform.
Add your website URL and name it accordingly. Click create a stream and, voila, you just got the ID number for your analytics.
You will notice a window named Tagging instructions. Since WordPress is a CMS-hosted site we need to use the global site tag.
This is the tracking code that you need to add to your WordPress website.
Copy and save it, or just leave this browser tab opened so you can copy it later. (Do you also keep too many tabs open, like me? 🙂 )
Hard work – CHECK!
Yup, that’s really it. And it wasn’t hard after all, right?
All there’s left to do is to connect Google Analytics with your WordPress website.
Add Google Analytics code With a WordPress plugin
Plugins FTW!
Even though you can also add it manually with a code (scroll down), I don’t really recommend doing it this way.
Most website owners are not tech-savvy, so MESSING with code is really out of the question.
And it really makes no sense these days.
I coded MANY websites, but I still prefer using plugins when adding features to WordPress sites.
These are my favorite Google Analytics plugins for WordPress:
Best WordPress Google Analytics Plugins
1. Insert Headers and Footers Plugin
You need to add the ID number that you got by following the above steps to your WordPress website’s header.
And because you want to avoid messing with the code and possibly crashing your website, you will install a WordPress plugin to do the job for you.
Insert Headers and Footers plugin is the QUICKEST way to add the code to your website.
What I like about this plugin is that it allows adding other scripts as well.
If in the future you need to add some custom coding, Facebook Pixel, or other tracking scripts to your website, the plugin will help you with that too.
After you install the plugin, head to Settings > Insert Headers and Footers.
All you have to do is copy and paste the ID number to the header.
Save changes and you are done.
You have successfully installed Google Analytics on your website and can already start tracking visitors.
MORE INFO / DOWNLOAD2. GA Google Analytics
Another simple plugin that will help you get started. After the installation head to Settings > Google Analytics.
Click the plugin settings and copy-paste your GA ID number.
Reminder: You received the code when you created a data stream (check the above screenshot).
And this is it.
For most users, this is an even more elegant solution as you only need the ID number.
I recommend this plugin if you like keeping things EXTREMELY simple.
MORE INFO / DOWNLOAD3. Lara’s Google Analytics
This is a more advanced plugin that not also adds the necessary code to your website, but offers an insightful dashboard where you can see the analytics data directly in WordPress.
You don’t need to leave your website’s admin to check visitors’ stats and more.
Note: This plugin comes with free and PRO versions.
But I suggest you try the free option first and go from there.
Free version features:
- Full access to analytics (sessions, users, page views, bounce rate, etc.)
- Simple installation
- All graphs within your WP dashboard
- Users separated by browsers used, gender, languages, operating systems, screen resolutions, etc.
- 30-day time range for metrics
PRO version features:
- Real-time user stats
- Check metrics for different date ranges (unlimited options)
- Shows keywords used in Google to visit your website
- Traffic sources (search, affiliates, direct, etc.)
If you want to have more stuff in one place – your WP admin – then Lara’s is your best bet!
MORE INFO / DOWNLOAD4. Google Analytics for WordPress by MonsterInsights
This is by far the most progressive plugin out there. It offers EVERYTHING you need (and don’t yet know you need).
That’s why I decided to only briefly mention it here, sharing a few of its advanced features.
I will dedicate a whole tutorial to this plugin to really explore everything it has to offer in the future.
Monsterinsights features:
- 3+ million active installations (!)
- Universal analytics & GA4
- Built-int Google Analytics dashboard
- Real-time statistics
- eCommerce reports & tracking
- Affiliate links & ads tracking
- Custom report settings
I would only SUGGEST not to use MonsterInsights if you don’t want to be bothered with TOO much data.
But you’ll eventually need to get used to the analytics data for better website optimization.
MORE INFO / DOWNLOADAdd Google Analytics Code Without A WordPress Plugin
In the end, let’s take a look at how to add the code without using a plugin.
Some users will always strive to have as few plugins as possible. (Which is good but not recommended for everyone.)
In the end, a plugin will SLOW down your website, at least a little bit, regardless of how well the plugin is coded.
This is the best solution if you want your website to run as fast as possible and don’t want to use analytics within your WordPress dashboard.
Add the code in the header.php file
Go to Appearance > Theme editor and click on the header.php in the right sidebar.
Note: You can also edit it on your computer and upload it via FTP.
Now edit the file and paste the code you copied before when you created your Google Analytics data stream.
Be VERY careful here as you need to add the code right after the <body> tag. Save the changes and you are done.
Add the code in the functions.php file
You can also add Google Analytics tracking code to the WordPress functions file.
You will need to add this code to your theme’s functions.php file.
1
2
3
4
5
6
7
|
<?php add_action( 'wp_head' , 'wpb_add_googleanalytics' ); function wpb_add_googleanalytics() { ?> // Paste your Google Analytics tracking code from Step 4 here <?php } ?> |
Remember: Both solutions are only for people who are comfortable with adding and editing code within the PHP files.
Don’t use these options if you are not familiar with coding.
We’re finally DONE.
You are now ready to start using Google Analytics’s amazing functions and take your site to the next level.
Teaser: I will explain how to use the data from Google Analytics to your advantage in a future tutorial.
FAQs About Installing Google Analytics In WP
How do I add Google Analytics to my WordPress site?
You can add Google Analytics to your WordPress site by installing a plugin like “GA Google Analytics” or by adding the tracking code directly to your theme’s header.php file. With a plugin, you just need to follow the setup wizard, connect your Google Analytics account, and the plugin will handle the rest. If adding the code manually, you’ll need to paste the Global Site Tag (gtag.js) provided by Google Analytics into the header section of your WordPress theme.
Can I install Google Analytics on WordPress without a plugin?
Yes, you can install Google Analytics without a plugin by adding your Google Analytics tracking code (Global Site Tag) to your WordPress theme’s header.php file. You can do this by editing the header.php file via Appearance > Theme Editor in the WordPress dashboard or by using “Insert Headers and Footers” plugin.
Where do I find my Google Analytics tracking code?
You can find your tracking code in your Google Analytics account. Navigate to Admin > Tracking Info > Tracking Code, and you’ll find your unique Global Site Tag (gtag.js) that needs to be copied and pasted into your WordPress site.
Is there a difference between installing Google Analytics on a WordPress.com and WordPress.org site?
Yes, there’s a difference. WordPress.com has built-in integration for Google Analytics only with its Business or eCommerce plans. You navigate to Tools > Marketing > Traffic in your WordPress.com dashboard to connect Google Analytics. For WordPress.org, you have to manually install Google Analytics either with a plugin or by editing your theme files.
How do I check if Google Analytics works on my WordPress site?
After installation, you can check if Google Analytics is working by visiting your website and then checking the Realtime report in your Google Analytics account to see if your visit is registered. Alternatively, you can use the “Tag Assistant” browser extension by Google to verify if the tracking code is firing correctly.
Does Google Analytics slow down my WordPress website?
Google Analytics itself is highly optimized and should not slow down your website. However, adding additional plugins or scripts can have a performance impact. It is best to use a minimal number of plugins and ensure they are well-coded and maintained to avoid slowing down your site. Using Google’s recommended asynchronous tracking code also ensures that it does not affect page loading times.
Do I need a Google Analytics account to use it with WordPress?
Yes, you need to sign up for a Google Analytics account at analytics.google.com. Once you’ve set up your account, you’ll receive a tracking ID that you’ll need to add to your WordPress site.
Can I view Google Analytics data directly in my WordPress dashboard?
Yes, plugins like “MonsterInsights” offer a feature that allows you to view Google Analytics data directly in your WordPress dashboard. Once configured, you can see key metrics without leaving your site.
How long does it take for Google Analytics to start tracking my WordPress site data?
It usually takes Google Analytics about 24 hours to start tracking data on your site. Once the tracking code is installed correctly, you’ll begin to see data populate in your Google Analytics account.