You can’t improve your WordPress website if you don’t know what’s happening on it.
Google Analytics gives you those insights for free. Although it may sound technical, you don’t need to be a developer to add it to WordPress.
In this guide, we’ll show you how to install Google Analytics in WordPress step by step.

Before you can connect your site, you need a Google Analytics account and a Measurement ID. If you already have both, you can skip ahead to the installation methods below.
How to Sign Up With Google Analytics
To start tracking your site visitors with Google Analytics, sign up for it with your Google account.
First, visit the Google Analytics website and click the ‘Get started today’ button. Then sign in with your Google account, or create one if you don’t have it yet.
Once you are signed in, click the ‘Start measuring’ button on the welcome screen. Google will then ask for an ‘Account name’, which only appears in your own account, so enter your business name here.

You can leave the data-sharing settings at their defaults and click ‘Next’.
Once your account exists, Google asks you to create a property. A property is simply the container that holds the data for one website. Enter a property name for your website, select your reporting time zone and currency, and then click the ‘Next’ button.

Google will then ask about your business industry, size, and goals. Answer these to match your business, click ‘Next’.
Now that your property is ready, Google needs to know where its data will come from. This is called a data stream. Since we are tracking a WordPress site, select ‘Web’ as the platform.

After that, enter your website URL and a stream name. By default, Google Analytics keeps ‘Enhanced measurement’ turned on, which tracks pageviews, scrolls, outbound clicks, file downloads, and more.
Next, click the ‘Create & continue’ button.

You will now see your stream details, including the Measurement ID. It starts with ‘G-‘ and is what connects your website to this Google Analytics property.

Google also shows an alert bar at the top with instructions for adding the tracking code to your site. Click the ‘View tag instructions’ button to see them.
Switch to the ‘Install manually’ tab, and you will see the Google Analytics tracking code. You only need this code for Methods 2 and 3 below.
If you plan to use the plugin method, MonsterInsights adds the code for you.

Keep this browser tab open. You may need to come back to it while installing the code on your WordPress site.
How to Install Google Analytics in WordPress
Now that you have your Google Analytics account and Measurement ID, let’s add the tracking to your WordPress site.
There are three ways to add Google Analytics to WordPress. We recommend using a Google Analytics plugin (Method 1) because it’s the easiest and safest option for most WordPress users. You won’t need to edit your theme files, plus you can see Analytics data directly from your WordPress dashboard.
The other two methods let you add the tracking code manually. They’re useful if you prefer not to use a plugin or want more control over how the code is added.
- Method 1: Install Google Analytics with an Analytics Plugin
- Method 2: Install Google Analytics in WordPress with WPCode (Manual)
- Method 3: Install Google Analytics in Your WordPress Theme (Advanced)
- Bonus Tip: Track More Analytics Data in Google Analytics
- Video Tutorial: Install Google Analytics in WordPress
Method 1: Install Google Analytics with an Analytics Plugin
The easiest way to add Google Analytics to WordPress is by using a Google Analytics plugin. We use and recommend the free MonsterInsights plugin. It connects your site to Google Analytics without touching any code and shows your traffic reports right inside the WordPress dashboard.
You can also find many other Analytics plugins, like Google Site Kit, which works well for basic pageview and search data. But unlike MonsterInsights, it doesn’t offer a Pro version and lacks many advanced features, like User Journey, which shows the exact conversion path a visitor took through your site.
For details, see our comparison of MonsterInsights vs. Site Kit.
First, you need to install and activate the MonsterInsights plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, MonsterInsights opens its setup wizard. If it doesn’t, go to the Insights » Settings page and click the ‘use our setup wizard’ link.
The wizard first asks which category best describes your website. Choose business website, publisher, or eCommerce, and then click the ‘Save and Continue’ button.
Next, you need to connect the plugin to your Google Analytics account. Click the ‘Connect MonsterInsights’ button.

This takes you to Google, where you choose the Google account you used to create your Analytics property. Then click ‘Allow’ so that MonsterInsights can access your Google Analytics data.
After that, select the property you created for your website from the dropdown menu and click the ‘Complete Connection’ button.

MonsterInsights will now add the tracking code to your site for you. All that’s left are a few screens where the wizard suggests settings based on the website category you picked earlier.
The defaults work well for most websites, so you can click ‘Save and Continue’ on each screen.
If you see a screen asking for a license key, just click the option to finish setup without upgrading.
That’s it! You’ve now successfully set up Google Analytics on your WordPress website.
View Google Analytics Reports Inside the WordPress Dashboard
Once Google Analytics has collected some data, you can see your reports without leaving WordPress. Visit the Insights » Reports page to see an overview of your traffic, top pages, and where your visitors come from.

Keep in mind that Google Analytics takes a few hours to start showing data after you install it.
Method 2: Install Google Analytics in WordPress with WPCode (Manual)
If you don’t want to use a dedicated Google Analytics plugin, then you can use the free WPCode plugin instead. WPCode keeps the code separate from your theme, so you won’t have to worry about losing it during theme updates or accidentally breaking your site while making changes.
First, install and activate the WPCode plugin. If you need help, see our guide on how to install a WordPress plugin.
Upon activation, go to the Code Snippets » Header & Footer page. Then paste the Google Analytics tracking code you copied while creating your Analytics account into the ‘Header’ box.

Don’t forget to click the ‘Save Changes’ button. Google Analytics is now installed on your site.
Method 3: Install Google Analytics in Your WordPress Theme (Advanced)
The last method skips plugins altogether and adds the tracking code directly to your theme.
Keep in mind that with this method, you will lose Analytics tracking whenever you update or switch your theme.
Simply add the following code at the bottom of your WordPress theme’s functions.php file.
add_action( 'wp_head', 'wpb_add_googleanalytics' );
function wpb_add_googleanalytics() { ?>
<!-- Paste your Google Analytics tracking code here -->
<?php }
Replace the comment line with the tracking code you copied from your Google Analytics account, and then save the file.
Your WordPress theme will now load the Google Analytics tracking code across your WordPress site.
Bonus Tip: Track More Analytics Data in Google Analytics
By default, Google Analytics tracks pageviews and basic engagement. However, it does not give you advanced reporting, like eCommerce tracking, affiliate link clicks, video tracking with Vimeo, and more.
With MonsterInsights Pro, you can enable additional tracking through addons. All you have to do is install the right addons by navigating to Insights » Addons page. Here is how to set up each one.
- eCommerce tracking: Enable the ‘eCommerce’ addon if you run a WooCommerce store, a digital downloads store, or a membership site. You can then see which products and customers bring in your revenue, and more.
- Set up form conversion tracking: Enable the ‘Forms’ addon to start tracking your form views, submissions, and conversion rates. MonsterInsights integrates with form plugins like WPForms, Formidable Forms, and more, so no additional configuration needed.
- Track video analytics: Enable the ‘Media’ addon to track whether people watch your videos or click away after a few seconds. It works with YouTube, Vimeo, and self-hosted HTML5 videos.
- Custom event tracking: With custom event tracking, you can record specific actions visitors take on your site, like a button click. It doesn’t need a separate addon to be installed.
For example, if you want to track a custom click event, then follow this formula:
<a href="https://www.example.com" data-vars-ga-category="Custom Category" data-vars-ga-action="Custom Action" data-vars-ga-label="Custom Label">Example</a>
Using this template, you’ll be able to override the default tracking behavior of MonsterInsights to customize what gets tracked as the category, action, and label. For example:
<a href="http://www.example.com/download.pdf" data-vars-ga-category="CTA">Download now</a>
To see the results, log in to your Google Analytics account and go to Reports » Engagement » Events. Your category name will appear in the list of events.

FAQs About Installing Google Analytics in WordPress
Here are answers to some of the most common questions we get about setting up Google Analytics.
Is Google Analytics free to use?
Yes, Google Analytics is completely free. Google offers a paid version for large enterprise websites, but the free version is more than enough for most small business sites and blogs.
How long does it take for Google Analytics to start working?
After you add the tracking code, Google Analytics may take a few hours to begin showing data in your reports. We recommend checking back after 24 hours to see your first full day of statistics.
Do I need Google Analytics if my site has Jetpack Stats?
Jetpack Stats gives you a simple overview of your traffic. Google Analytics goes much deeper, with detail about your audience, their behavior, and how they found your site.
For a full comparison, see our article on Google Analytics vs. Jetpack Stats.
How do I keep personally identifiable information (PII) out of Google Analytics?
Google’s terms do not allow you to send personal details like names, email addresses, or phone numbers to Google Analytics. To ensure you’re not accidentally adding such details via forms, you can go to Admin » Data streams and select your website’s stream in your Google Analytics Account. Then click ‘Redact data’ and strip any URL parameters.
If you use MonsterInsights, the Privacy Guard feature does this automatically from Insights » Settings » Engagement. It is included in the Plus plan and higher.
Video Tutorial: Install Google Analytics in WordPress
If you prefer to watch the process, our video tutorial shows you how to install Google Analytics in WordPress.
We hope this article helped you learn how to install Google Analytics in WordPress.
Next, you may want to see our ultimate guide to GA4 in WordPress to make sense of your new reports. You can also check our WordPress SEO guide for tips on growing your traffic in AI search era.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


Dave
I run a marketplace website that enables content owners sell their products. So I want each owner to be able to see, in real time, the analytics of each product they own, like number of items sold, how much was made, customer location, etc. when they login to their portal. Is this feature available with MonsterInsights?
WPBeginner Support
Hi Dave,
It is actually done by your eCommerce software. Please see our guide on how to create an online marketplace using WordPress.
Admin
Paul Larkin
Excellent. Brilliant. Very clear explanation. Easy to follow. I used Monster Insights and it was exactly as you said. Many, Many, Thanks, Paul
Darlene
Hi. I already have a google analytics account and just want to transfer or sync it with my wordpress blog. How can I do that without starting a whole new account and starting over?
WPBeginner Support
Hi Darlene,
If it is for the same website, then you can follow the instructions above to install Google Analytics.
Admin
Troy
Will it work in a free plan?
WPBeginner Support
Hi Troy,
Yes it would.
Admin
Tikyda
Thanks a lot for sharing this tutorial. It seems that it went faster than I expected. I have used Monster Insights plugin.
Diogo
Great post!
Just one doubt: Can I use this on WordPress.com Premium plan?
Cheers!
WPBeginner Support
Hi Diogo,
You can only install plugins on WordPress.com Business plans. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
Admin
Thessa
Thank you so much for all the information, I understand this all much better than what any other person taught me.
Christian Laurin
Great instructions, so clear and works perfectly, thanks a lot guys !
Charlene Marsh
I just installed and activated this plugin but I do not have the Dashboard option listed. Under Insights on my Wordpress Dashboard I have Reports, Settings, Tools, and Addons. Is the Insights Dashboard a paid feature? I am using version 7.0.0 of MonsterInsights by Google Analytics for WordPress by MonsterInsights. Thanks.
WPBeginner Support
Hi Charlene,
No you are seeing it correctly. The Reports page is the plugins overview page as well as dashboard where you can see your Google Analytics reports.
Admin
Malik
Awesome
I have followed same procedure and it worked quite well
Thanks
Joel
Your a life saver, thanks for the post!
Polina
Hi, when I’m trying to Authenticate my Google Analytics account with MonsterInsights , it’s said “error, cannot connect to google”, where can be my mistake? thank you
WPBeginner Support
Hi Polina,
Please try again in a few minutes. If you still see the error make sure you are signed in with the same Google account you use for Google Analytics.
Admin
CeCe
When I tried entering the Google Analytics code, I got an error saying “Bad Google Code. Try Again.” I haven’t launched my blog yet (Feb 1st to be exact), so I don’t have any posts published. Is that why I would get that error?
WPBeginner Support
Hi CeCe,
No, you can still add Google Analytics to your website. You need to carefully cope the authentication and paste it. Make sure you are signed in using the same Google Account you used to create Google Analytics.
Admin
katchen gerig
awesome, you totally answered all my questions. Thank you!
Joy
Thank you so much for these directions.
Tish Winchester
These directions were spot on. Thank you so much!
Jessy
Very helpful indeed. Thanks for helping us the novice users of Wordpress.
Pramita
Thanks so much. I lost my website like 2 years ago and i can’t remember how to get the google analytics plugin which previously was maintained by Yoast, now that i read this, i know it now goes with the name monsterinsight. Keep it up!
Sylvia
Thanks for the tutorial video I was able to install it on my site.
Theresa
Hi,
I hope you can help me out. I’ve been trying to set up google analytics but ghostery and adblock might be preventing me to get the tracking id. I’ve already whitelisted and unblocked the site but to no avail. Thanks.
WPBeginner Support
Hi Theresa,
You can use a different browser like Firefox or Opera without installing those addons, you can also uninstall those addons temporarily. Set up your Google Analytics and then start using your regular browser with these addons.
Admin
TYRONE
you’ll need to disable ghostery and adblock in order for the Google website to load properly.
Ivan
The Monster insights plugin works! Other methods that I found online like inserting the code into the header.php file did not generate any results at all. Thank you for posting this.
Adrian Wagar
This is exactly what I was looking for – thanks! The Monster Insights plugin works perfectly.
brabusday
thank you very much that you share really useful gratitude teacher
rafik
hi , i just insert the google analytics in header.php , and it desapear , i guess i did it wrong , the think is my google map in my website aint working no more , so there is any way i can reverse that code or roll back to deleted it ?, thank you
Porag
Will there be any problem(s) if I don’t install the “Insert Headers and Footers Plugin” after installing and setting up Google Analytics on my site?
Graham
Hate Wordpress, but loved the tutorial. Learned a lot and solved my problem (how to add Google Analytics code to my header) within minutes. Many thanks.
sanjay dhunna
Hi, the article is really helpful, i used Monster Insight for my site as suggested and explained clearly.
David
Hey, great article! I used monster plugin but now I want to verify my google search console by my google analytics account and its not working. Can I verify google search console by syncing my GA account with my website only through monsterinsights?
Thanks!
Anand
Thanks for the simple and useful article. I was able to use this to setup Google analytics for my site
Thanks & Regards
Kelly
I have just set up Monsterinsights on my Wordpress website (I use .org). I use the theme Onepress Plus. Does this mean if I do a update of the theme my analytics will be gone from the code?
WPBeginner Support
Hi Kelly,
If you are using MonsterInsights, then your Google Analytics settings will not change when you update or change your WordPress theme.
Admin
Nikhil bansal
Please help me i unabke to choose my profile of analytify in profile option there is nothing. Why?
How to solve it?
WPBeginner Support
Please update your plugin or contact plugin’s support team.
Admin
Chris
We have a problem here, the site stopped tracking in july and we cant find why… Thoughts? we changed servers but only point the domain to the new ones to url:s didn’t move…
Karthik
Hi,
After i install the Google Analytics and Header & footer plugin my whole website stopped working.
Now how do i remove those plugins from my WordPress?
Rosana
Thank youuuu!! Help me a lottt!
Tony Ricardo
Thanks a lot for ur help
this is help me a lot
Kamille
What plugin and how do you insert “subscribe button” on your embedded YouTube video? Thank you. Hoping for a response.
Zoe Brannagan
So grateful for this! Thank you!
Shelley
This is only one out of many of your articles that has helped me get my website up and going. Thank you!
bamidele
thank you for the info,is very helpful. GOD bless you guys at wpbeginner.
Ellen
Doesn’t work because I have a free wordpress.com blogsite. So not possible to add plugins. So disappointed

If you have any advice for me. Please let me know
Kenneth
I know! Same problem for me. Did you find a solution?
Beth
Same here. Any workaround?
Giacomo Lawrance
Does monsterinsights reduce page loading speed?
simon rodie
Hi,
I just upgraded to the business plan so i could install monster insights but as some others have written when I go to put in the code it says BAD CODE. When I go back to the beginning and login to my google account and click Get Code and go through the steps it just returns to the original screen.
What should i do guys?
WPBeginner Support
Hi Simon,
We recommend using self hosted WordPress. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
You can also reach out MonsterInsights support team for help as well.
Admin
Nee
Can I paste the code into function.php of child theme?
WPBeginner Support
Yes, you can.
Admin
Anna Sjostrom Walton
Thanks for the great guide! On the Google Analytics page where the tracking ID appears, it also has the Universal Analytics Tracking Code and says:
To get all the benefits of Universal Analytics for this property, copy and paste this code into every web page that you want to track.
Do I need to do this, or does MonsterInsights take care of tracking each page on my website? (I didn’t need to enter the Tracking ID from this page, as MonsterInsights found it).
Thanks!
WPBeginner Support
Hi Anna,
Once you have installed MonsterInsights, it will take care of tracking all pages on your WordPress site.
Admin
Hifa
Hello,
After I install the plugin its add the analytics.js for 2 pages only why??
Thank you in advance
Erin
Do you need to have Wordpress.org for this or can I still use it with Wordpress.com?
WPBeginner Support
Hey Erin,
You cannot use Google Analytics on WordPress.com unless you upgrade to their business plan. Please see our guide on the difference between self hosted WordPress.org vs free WordPress.com blog.
Admin
Jessica Greenhood
It would be really great if you had said that at the beginning. Do you know how many places I’ve looked for how to do this and not one of them mention you have to have the business plan and not be on .com but on .org.
Radha
Thanks a ton for saving tremendous man hours through your guidance….. This article especially helped me in setting up analytics for my blog in less than 30 mins (that includes reading,setting up, testing on WP&GA)
Nee
Hi, I have a few different views for my analytics. Say I have activated View 1 for Monster Insight, does all the views in Google Analytics still runs?
Tomas
Great stuff. One way would have been ok. Three are even greater. Thanks!
Siaki
Thank you. You were very helpful!
Nicky
Thanks, that was really helpful & easy.
Kate
Hi, I’ve followed all your instructions for the monster insights steps, but when I get the code, it keeps saying bad code, or ensure your account is signed up for analytics. I think it all is, I’ve authenticated it? Are you able to help? I don’t know what else to try!
WPBeginner Support
Hey Kate,
Please make sure that you are using the same Google account that you used to sign up for analytics. You can signout of your Google account, and then sign back in to make sure that you are using the same Google account.
Also go to your Google Analytics dashboard and see if you can see your website profile there.
Admin