Google Analytics is a free and comprehensive tool for tracking web traffic and data.
Google Analytics tells you how many people visit your site, individual pages, conversions, and how users interact with your content. This data is important for website optimization.
There are two types of Google Analytics code.
You may be familiar with Google Universal Analytics (UA) code. It is deprecated and replaced by Google Analytics 4 (GA4).
GA4 is much more customizable and can be applied to websites and apps, whereas Google UA can only be applied to websites.
Set up Google Analytics on your website
First, set up a free Google Analytics account.
You will be asked to sign in with your Gmail account. Doing this will log you in.
On the next screen, create an account name. We recommend using something broad, such as your business name, as you can track multiple sites with one account.
Then set the properties. This should include the website name, time zone, and currency used at this business location.
The next screen asks a few questions about your business and how you use Google Analytics.
Click on Terms and Conditions and select Email Communication, and you will be taken to the admin dashboard.
Next, set up the data stream.
If you want to add Google Analytics to your WordPress site, you should select “Web Stream”.
Then add your site URL and site name.
once hit create stream Click the button to see the stream name, stream URL, stream ID, and measurement ID.
The measurement ID is what you use to add to your website.
Add Google Analytics to Your WordPress Website
There are three ways to add Google Analytics to your WordPress site.
The best option depends on your comfort level in modifying your website’s code.
The first option uses a WordPress plugin to add Google Analytics to your website without any coding required.
The second option involves using a WordPress plugin and copying and pasting a small amount of code.
The third option requires editing the code in your website’s theme file.
1. Use of the Google Analytics Plugin
The easiest way to add the Google Analytics tag code to WordPress is with a plugin.
Google Analytics for WordPress by MonsterInsights is the most popular and easy to add Google Analytics code to your site.
The free version should work fine unless you need advanced tracking and reporting features. Then upgrade to the Pro version.
- Step 1: Install and enable the MonsterInsights plugin.
- Step 2: Launch the wizard and enter information about your site,[Connect MonsterInsights]Click the button. This will bring up a few pages of settings that need to be pre-selected for setup.
- Step 3: Next, you will be asked to sign in to your Gmail account and asked for permission to access your Google account.
- Step 4:[許可]Click to display the connected Google Analytics account.
- Step 5:[完全な接続]Click to connect to your Google Analytics account. It ends by offering an upgrade to Pro, but you can select the link at the bottom to complete the installation without upgrading.
Now everything is set up and you can see your insights in your WordPress dashboard. Reports, settings, and other selected tools are now visible in your WordPress dashboard.
2. Using the Header/Footer Script Plugin
The second way to install the Google Analytics tag is through the Header/Footer plugin.
This method can be used both for specific pages and for the entire site, so it’s especially useful for tracking metrics that vary from page to page.
WPCode Header & Footer Insert + Custom Code Snippets – WordPress Code Manager is the most popular plugin for inserting header and footer code, used by over 1 million users.
- Step 1: Install the Header and Footer plugin on your WordPress site.
- Step 2: In your Google Analytics account,[タグ付け手順]Click[手動でインストール]Select a tab.
- Step 3: Copy the Google tag code.
- Step 4: You will see the Code Snippets plugin in the left navigation menu of your WordPress dashboard.
- Step 5: In the dropdown[ヘッダーとフッター]and paste the code into the header section.
- Step 6:[変更を保存]Click.
- Optional Step: To add code to a specific page or post, select the page or post and scroll to the bottom. Add the appropriate Google Analytics code to the header section of that page.[更新]Click to save your changes.
3. Add the Google Analytics code snippet directly to your Header.php file
This is another option for adding Google Analytics code if you are comfortable working directly with your theme code. Note that since you’re modifying the theme file directly, if you change or update your theme, your Google Analytics code will be lost and you’ll have to re-add the code every time you update or change your theme.
- Step 1: In your WordPress dashboard, exterior > theme file editor.
- Step 2: Select a parent theme and header.php.
- Step 3: Finish Copy and paste the code just before the element.
- Step 4:[ファイルの更新]Click to save your changes.
WordPress theme files, August 2022
Check Google Analytics tag
After installing the Google Analytics tag on your website, you can use the Google Chrome extension Tag Assistant (Legacy) to verify that the Google Analytics tag is installed and working properly.
Simply install the Chome extension in your browser and navigate to your WordPress site with Google Analytics installed to see if there are any tags and errors on your site.
After installing Google Analytics on your WordPress site
Installing the Google Analytics tag allows you to view dashboards from the Google Analytics site.
Alternatively, if you choose the MonsterInsight plugin method of installing Google Analytics on your WordPress site, you can view reports and data directly from within your WordPress dashboard.
Google Analytics is a powerful tool that helps you understand how visitors access and use your website, how pages are converting, how many people are visiting your website, and more. Tool.
You can easily add the Google Analytics tag to your WordPress site using one of three methods:
- Google Analytics plugins (such as MonsterInsights).
- Header/Footer plugins (such as WPCode).
- Add it directly to your theme’s header.php file.
You can use Google Analytics data to gain valuable insight into your website traffic and make improvements.
Please note that Google Analytics cannot collect data retroactively. That’s why it’s important to add Google Analytics to your website sooner or later to avoid missing data.
Featured Image: Andrey_Popov/Shutterstock