How to add google analytics to a website in 2022


Do you want to lớn learn how to địa chỉ cửa hàng Google Analytics to lớn WordPress? Knowing why people visit your site and use your nội dung is crucial for increasing your traffic và subscribers.

Bạn đang xem: How to add google analytics to a website in 2022

The easiest way khổng lồ learn more about your audience is to analyze your site’s statistics. And Google Analytics lets you vì chưng that for free.

This article will tóm tắt why website analytics are important and how to lớn set up web analytics on your WordPress website khổng lồ track and view them.

Why Is google analytics Important?

Google Analytics is a không tính phí analytics solution for any type of website.

Learning about your trang web analytics is crucial for improving your website traffic. With more traffic, you can turn visitors into leads & subscribers, resulting in more revenue for your business.

By adding web analytics to WordPress, you can track the data you need lớn gain insights for growing your business. Additionally, it helps you know what to vì chưng next & which tactics to avoid when you optimize your site.

With Google Analytics, you can collect statistics like:

Total number of website visitorsWhere visitors come fromWhich content is most popularAnd much more

Here are several ways web analytics can help grow your business & improve your marketing strategy:

Learn More About Your Visitors: With web analytics for WordPress, you can collect crucial informaiton about your trang web visitors. That way, you can personalize your kinh doanh strategy lớn fit thier needs và interests.Understand How Visitors Engage with Your Content: By adding web analytics to WordPress, you can learn what people are doing on your site. For example, you can see the pages they visit, how long they stay, và more.Learn How Visitors Find Your Site: Integrating web analytics with WordPress, allows you to access tracking information about how visitors found your website. For instance, they may come from social media, Google search, or another website.Problem Solve When Things Go Wrong: When you showroom Google Analytics lớn WordPress, all of your site’s data is at your finger tips. So if you notice any issues with your traffic or sales, you can find them & fix them fast to reduce lost revenue.

In the end, google analytics gives you all the information you need lớn make the right decisions to grow your business, with advanced options khổng lồ test và optimize your site.

We’ll explain how you can sign up for web analytics before showing you how to add Google Analytics khổng lồ WordPress.

How bởi I Sign Up for Google Analytics?

Before you learn how lớn set up google analytics on your WordPress website, you need lớn sign up for a google analytics account. Follow the steps below to lớn learn how.

Step 1: Visit the google analytics Homepage

First, go khổng lồ the web analytics homepage lớn sign up.

You’ll then see a popup where you can use your credentials to sign in if you already have a Google account.


On the next screen, you can choose between adding a…

WebsiteAppApp & website

Choose the Website option and click Next.


Step 3: Enter Your trang web Details

The next page is where you can create a google analytics property và enter the details for your sites, such as your website name, timezone, and currency. You can track more than one trang web in Google’s analytics dashboard & pick a name appropriate for each site.


Then, toggle the “Create a Universal Analytics Property” option to the ‘On’ position.


You also need lớn click the checkbox next to lớn the heading called “Create a Universal Analytics property only.” Otherwise, you may face issues connecting to lớn MonsterInsights, which we’ll show you how to do later.

Now click Next.

You’ll have to accept & agree lớn Google’s terms & conditions next. So click,I Acceptto move on.

Step 4: Copy Your google analytics Tracking Code

After that, you’ll see a screen with your google analytics Tracking ID và Google Analytics tracking code. Go ahead and copy your tracking code, as you’ll need to showroom it lớn your website, depending on which method you use below.


It’s a good idea lớn leave this page open in your web browser, as you may need to lớn refer back to lớn it once you’ve installed the google analytics code on your website.

Now that you’ve mix up your Google Analytics trương mục let’s look at how to add Google Analytics to lớn your website.

How vì I showroom Google Analytics to lớn My WordPress Site?

There are several ways to lớn set up web analytics on WordPress. Below we’ll show you 4 different methods. The first method involves using a google analytics WordPress plugin, while the last is more difficult lớn achieve for beginners.

You’ll only need to lớn use one of these methods to lớn install google analytics in WordPress.

Method 1: địa chỉ Google Analytics lớn WordPress with MonsterInsights


We’ll use a plugin to lớn set up your tracking information for the first method. MonsterInsights is the best WordPress google analytics plugin và the easiest way to add Google Analytics khổng lồ WordPress for beginners & experts.

MonsterInsights is not only the easiest solution, but it also has heaps of advantages over manual methods, including:

WordPress analytics reporting:Actionable data và insights within the WordPress dashboardeCommerce tracking: mix up tracking for WooCommerce, Easy Digital Downloads, LifterLMS, và MemberPress with 1 clickAffiliate tracking:Use web analytics reports in MonsterInsights to lớn find out which affiliate link are getting the most clicks to lớn maximize your revenueGoogle AdSense tracking:Easily see who’s clicking your adsDownload monitoring:See how many downloads your files are getting with custom reportsAuthor stats:Find out traffic and engagement statistics for each tác giả on your blogAdvanced Tracking: with optional AddonsDual Tracking: Connect khổng lồ Universal Analytics and Google Analytics 4 (GA4) at the same time.

And you can vì chưng all this without knowing or understanding how to code, which can be tricky for small business owners.

Note:MonsterInsights used to lớn be known as google analytics for WordPress by Yoast. WPBeginner’s founder, Syed Balkhi, acquired the plugin in năm 2016 and changed it lớn MonsterInsights. Now it’s part of their family ofpremium WordPress plugins.

Follow these simple step-by-step instructions lớn set up web analytics in WordPress with MonsterInsights.

Note: There is a miễn phí versionand a paid version of MonsterInsights. For this guide, we’ll be using the paid version.

Step 1: download and Install MonsterInsights

You can get the google analytics for WordPress by MonsterInsights download here if you haven’t already done so. Then save it to lớn your computer and install và activate the plugin.

Install the MonsterInsights plugin by navigating to Plugins » add New from your WordPress dashboard. Then click Choose Now to find the plugin .zip tệp tin on your computer và click Install Now.

When you purchase your copy, you will have received a license key that you can view in your MonsterInsights trương mục area.

Copy that key and showroom it lớn the blank License Key area in WordPress. Then click Verify.

Step 2: Connect MonsterInsights

Once your license is verified, scroll further down the page where you’ll see 2 options labeled:

Connect MonsterInsightsLaunch thiết đặt Wizard

For this step, you’ll need lớn click the Connect MonsterInsights option.


After this, you’ll go khổng lồ another page where you can authenticate your Google account. Then you’ll see a message from MonsterInsights asking for permission khổng lồ access your account.

To provide access, go ahead & click the Allow button.


You can select the trang web you’d like to collect data for on the next page.


To complete the process, click on the Complete Connection button, and that’s it.

If you have both a Universal Analytics property & a web analytics 4 (GA4) property, you can also set up dual tracking with MonsterInsights.

Go to lớn the main Settings page, scroll down lớn Google Authentication, và find the Dual Tracking Profile box to lớn set up dual tracking.


Enter your Universal Analytics Tracking ID or your GA4 Measurement ID, whichever one you didn’t authenticate in the thiết đặt wizard.

Xem thêm: So Sánh Win 7 Pro Và Ultimate Cái Nào Tốt Hơn? Win 7 Ultimate Là Gì

Step 3: View Your web analytics Reports in WordPress

Now you can check Google Analytics reports directly on your WordPress dashboard.

To vì this, click on Insights » Reports from within the WordPress admin area. You’ll then see the reports right on your screen.


And if you scroll down your page, you can view more details, including your top referrals, đứng top posts and pages, top countries, tỷ lệ thoát rate, và more.

There’s no more logging into other websites to view your stats now. Instead, the information you need khổng lồ track visitors and make informed decisions about your site is all on your dashboard.

For google analytics to start tracking your trang web visitors, you’ll need to showroom the code above khổng lồ every page of your website. Here are some different methods to lớn help you mix up google analytics manually.

Method 2: địa chỉ Google Analytics khổng lồ WordPress with Insert Headers and Footers Plugin

The following method isn’t as useful as MonsterInsights because you can’t use advanced tracking và see your analytics data in your WordPress dashboard.

First, copy the analytics tracking code you saved when setting up your analytics account.


Then install and activate the Insert Headers and Footers plugin on your website.

After activating the plugin, navigate toSettings » Insert Headers và Footersfrom your WordPress dashboard. Then in theScripts in Headersection, paste your web analytics tracking code.


Finally, click the Save button. Now you’ve successfully added web analytics to your website!

Method 3: địa chỉ cửa hàng Google Analytics With Google Tag Manager

Google Tag Manager is a tag management system (TMS) that lets you manage different tags on your website. It also helps you deploy different code types, like your google analytics tracking code, without having khổng lồ edit your website.

Follow these simple steps to địa chỉ cửa hàng Google Analytics with Google Tag Manager to lớn your WordPress site.

Step 1: Create a Google Tag Manager Account

First, you need lớn sign up for Google Tag Manager và create a new trương mục by entering an Account Name.


Now move on khổng lồ the Container Setup. Here enter your Container Name, your website, and select Web as your Target Platform.


Click Create to continue.

Now click yes to agree lớn Google Tag Manager’s Terms of Service. Then you’ll receive the tracking codes to add to your website.

Step 2: địa chỉ cửa hàng the Tag Manager Snippet khổng lồ Your Header

The next step is simple. Copy and paste the code snippet into your header.php tệp tin in WordPress.

To vì this, follow the steps we explained in Method 1.

Step 3: địa chỉ a New Tag in Google Tag Manager

To get web analytics connected lớn Google Tag Manager, start by clicking New Tag.


You can rename your tag if you’d lượt thích to and click the Tag Configuration icon to lớn choose your tag type.


Then choose Google Analytics: Universal Analytics.


You’ll have to lớn enter your Tracking ID, which we explained how lớn find earlier, and your Tracking Type.

For this example, let’s choose the Pageview tracking type.


Now, click the icon under the Triggering section to open up the settings.

You’ll need to lớn choose the All Pages page view for adding Google Analytics.


Now click Save, and you’re done!

How vị I địa chỉ Google Analytics to WordPress Without Plugins?

This method is for users familiar with editing their site’s code. However, it’s an unreliable solution because the tracking code goes in your WordPress theme header. You’ll thảm bại the changes you make if you update your WordPress theme.

First, you’ll need to lớn copy your analytics tracking code; then, you need to showroom the code lớn your theme files. There are 2 ways to do this, which we’ll highlight next.

But before you try these methods, you must make sure you’re using aWordPress child themeto make these changes. Otherwise, when you update your parent theme, you could overwrite your tracking info, resulting in your global site tag (gtag.js) being removed from your site.

1. địa chỉ cửa hàng the Analytics Code in Your header.php File

To vị this, you need lớn find the header HTML section of your site. In WordPress, this is called your themes header.php file, and you can find it by going toAppearance » Theme Editor.

Then scroll through the files until you find the right one & click to open and edit it.

Paste your web analytics tracking code into the file right before the closing bracket, as shown below.


Then click Update File, & you’re done!

2. Showroom the Tracking ID to the functions.php

Another way lớn set up web analytics in WordPress without a plugin is to lớn use the functions file. This will showroom your tracking id lớn every page of your website.

To find where to lớn place your google analytics tracking code, locate your theme’sfunctions.php tệp tin by navigating toAppearance » Editorfrom the WordPress dashboard.

Then scroll through your theme files until you locate the one labeled functions.php, which is your Theme Functions.


Then showroom the following code snippet into the tệp tin using your tracking ID.

add_action("wp_head", "wpb_add_googleanalytics"); function wpb_add_googleanalytics() { ?> // Paste your google analytics tracking code from Step 4 here Click Update File when you’re finished, and Google Analytics should start working right away.

How to lớn View Your web analytics Reports

Now that you know how to connect google analytics to WordPress, you can start checking your data.

However, it takes Google time to collect & report the information through the web analytics dashboard.

So wait for at least 48 hours before you look at the collected google analytics data.

Once the waiting period is over, you can kiểm tra your web analytics data by going to Then, you can even get a glimpse of your real-time stats, which you can use as part of your SEO strategy.

Some of the information you can gather includes:

Demographics – The age & gender of your audienceGeographics – Visitor languages, locations, and time zoneBehavior – New vs. Returning visitors, frequency, & engagementSearch Console– Learn what people are typing into Google to lớn find your site

But if you’ve used the manual method, you won’t be able lớn see any stats in WordPress. We suggest using method 1 lớn connect web analytics to WordPress with MonsterInsights.

Xem thêm: Cách Nâng Cấp Cpu Từ Core 2 Duo Trở Lên Giá Rẻ Sinh Viên, Cách Nâng Cấp Cpu Từ Core 2 Duo Trở Lên

That’s it!

If you liked this tutorial, you might want to kiểm tra out our guide on how khổng lồ put your WordPress site in maintenance mode so you can hide your site while making updates. And if you’d lượt thích to know how to add a contact form khổng lồ WordPress, take a look at this tutorial.