Google Analytics is a free, all-inclusive tool for tracking web traffic and data. Google Analytics will show you how many people visit your site, which pages they visit, how many converts, and how they interact with your content. This information is critical for optimizing your website.
Google Analytics code comes in two varieties.
The Google Universal Analytics (UA) code may be one you are already familiar with. This is gradually being replaced by Google Analytics 4. (GA4).
GA4 is much more customizable and can be used on websites and apps, whereas Google UA can only be used on websites.
Installing Google Analytics on Your Website
The first thing you should do is create a free Google Analytics account. You must sign in using your Gmail account. After that, you will have logged in successfully.
Select the button labeled “Begin Measuring.”
The next screen will ask you to enter a name for your account. Because you can track multiple sites with a single account, you should choose something broad, such as your company’s name.
The following screen will inquire about your company and how you intend to use Google Analytics.
You will be taken to the admin dashboard after clicking on the terms of the agreement and selecting email communications.
After that, you’ll want to configure the data stream. When adding Google Analytics to a WordPress site, choose “web stream.”
You will then enter your site’s URL and name.
When you click the Create Stream button, the stream name, URL, stream id, and measurement id will be displayed.
You will use the measurement id to add to your website.
Adding Google Analytics To Your WordPress Website
There are three methods for adding Google Analytics to any WordPress site.
The best option for you will be determined by your level of comfort with making changes to your website code.
The first option involves the use of a WordPress plugin to add Google Analytics to your website without the need for coding.
The second option employs a WordPress plugin that requires only a small amount of code to be copied and pasted.
The third choice necessitates editing the theme files for your website’s code.
#1 . Using The Google Analytics Plugin
A plugin is the most convenient way to add your Google Analytics tag code to WordPress.
The most well-liked and convenient way to integrate your Google Analytics code into your website is using MonsterInsights’ Google Analytics for WordPress.
The free version should suffice unless you require advanced tracking and reporting features. Then you want to think about purchasing the pro version.
- Step 1: Installing and enabling the MonsterInsights plugin is the first step.
- Step 2: Open the Wizard, enter the details of your website, and press the Connect MonsterInsights button. This will guide you through a few pages of pre-selected settings for your setup.
- Step 3: The following step will ask you to sign in to your Gmail account and grant access to your Google account.
- Step 4: After clicking Allow, the Google Analytics account to which it will connect will be displayed.
- Step 5: Hit Complete Connection to connect to your Google Analytics account. It will finish up by offering an upgrade to Pro, but you can select the link at the bottom to finish the installation without upgrading.
You are now completely set up, and you will see Insights in your WordPress dashboard. Reports, Settings, and any other tools that have been selected are now visible in the WordPress dashboard.
#2. Using The Header/Footer Script Plugin
A header/footer plugin is the second approach to inserting your Google Analytics tag.
This technique is especially useful if you want to monitor various metrics for various pages because it can be used for both individual pages and the full website.
WPCode Insert Headers and Footers and custom code snippets – WordPress Code Manager is the most popular plugin for inserting header and footer code, with over 1 million users.
- Installing the Headers and Footers plugin in WordPress is the first step.
- Choose the Install Manually button under Tagging Instructions in your Google Analytics account.
- Copy the Google Tag code in step three.
- In the left-hand navigation menu of your WordPress dashboard, you will find the Code Snippets plugin.
- In the Header area, paste your code after choosing Header & Footer from the drop-down menu.
- Hit Save Changes in step six.
Optional Step: To add code to a specific page or post, select the page or post and scroll to the bottom. Add the proper Google Analytics code in the header section of that page. Impact Update to save your changes.
#3. Add Google Analytics Code Snippet Directly To The Header.php File
This is an additional option for inserting your Google Analytics code if you feel comfortable working directly in your theme code. Because you are making direct changes to the theme files, if you update or change your theme, your Google Analytics code will be lost and you will need to re-upload it.
- Step 1: In the WordPress dashboard, go to Appearance > Theme File Editor.
- Step 2: Select the parent theme and the header.php.
- Step 3: Copy and paste the code right before the closing </head> element.
- Step 4: Click Update File to save your changes.
Verifying Your Google Analytics Tags
After you’ve added your Google Analytics tag to your website, you can use the Tag Assistant (Legacy) by Google Chrome Extension to ensure that it’s properly installed and operational.
Install the Chome browser extension, go to the WordPress site on which you installed Google Analytics, and it will inform you of the tags that are there and whether there are any issues.
Having Installed Google Analytics on Your WordPress Site
After installing your Google Analytics tag, you may access the dashboard on the Google Analytics website.
As an alternative, you can access the reports and statistics from within your WordPress dashboard if you chose to install Google Analytics on your WordPress site via the MonsterInsight plugin technique.
Using Google Analytics, you can learn a lot about how people find and use your website, how well pages convert, how many people are visiting your site, and much more.
With one of these three approaches, adding the Google Analytics tag to a WordPress site is simple:
- Google Analytics plugin (such as MonsterInsights).
- Header/Footer plugin (such as WPCode).
- Add directly to theme header.php file.
You can use the data from Google Analytics to gain valuable insights into your website traffic which will allow you to make improvements.
It’s worth noting that Google Analytics cannot collect data retrospectively, so it’s important to add Google Analytics to your website sooner rather than later to avoid missing any data.