Google Analytics Tracking Code in WordPress – Step by Step
Google Analytics is a fundamental tool for measuring the popularity of a website, such as one on the WordPress platform. Google Analytics is completely free and offers significant benefits for those looking to increase the popularity of their website and gain analytical data on the WordPress platform. Installing the Google Analytics tracking code on your website is one of the first steps in using this tool.
Where to find your tracking code? You can find your tracking code in your website's Google Analytics dashboard . Go to the Administration tab and then, in the Property column, select Tracking Information > Tracking Code.

Now that we have our code, it's time to add it to the website. Below, I'll show you several methods for doing so. Method 1: In the WordPress dashboard, select the "Appearance" tab and then "Editor."

This is the editor that's active on the theme page. On the right side, you'll find a list of files. Google suggests placing the analytics code in the header, located in the "header.php" file – select it.
(The rest of the article can be found below the form)

Then we paste our Analytics code before the closing header tag

Click "Update file," which will save our code to the website. Method 2: The next method requires access to the FTP server where our website is hosted. First, log in to our FTP server using, for example, PSPad or Total Commander. We're interested in the header.php file, which typically contains the code we want to modify. Go to the following directory: wp-content > themes > select the directory with the active theme* > header.php *(If you don't know what it is, simply open the website in your browser, click CTRL+U, then CTRL+F, and enter "/themes/"; the active theme will be displayed on the right.)

Then we edit the header.php file

As in the case of the editor, here we also find the line, enter the analytics code before it and save the file on the server.

Method 3: We can also use one of the many available Google Analytics plugins . Here, I'll show you how to insert the code using the popular Google Analytics plugin by MonsterInsights. This application has many advanced options that allow you to measure additional data, such as file downloads, but for now, we'll focus on inserting the Analytics code itself. To install the plugin, go to your WordPress dashboard and select "Plugins" > "Add New." Then, search for the plugin you're interested in.

We find the application from among many available and click the "Install" option.

We will be taken to the plugin installation window, where after unpacking we enable the plugin.

The installed program will appear in the plugin panel – Google Analytics by MonsterInsights, go to its settings.

The window that opens has many tabs and options, but we're interested in manually entering the UA* code. We check the appropriate box, enter the string, and save the changes.

* What exactly is a UA code? It's a string of characters (called a tracking ID), for example, UA-111111-22, that tells Google which account to send data to. The numbers 111111 is the account number, while 22 identifies the property number assigned to the account. The tracking ID can be found in our analytics code:

Once the code is placed on the website, you need to wait 24-48 hours for the data we need to start collecting.
GA Tracking Code FAQs
The tracking code is located in your Google Analytics dashboard. To download it, go to the "Administration" tab, then in the Property column, select "Tracking Information," and then "Tracking Code."
In your WordPress admin panel, select the "Appearance" tab from the menu, then "Editor" (Theme File Editor). On the right, select the header file (header.php) from the list of files for your active theme. Paste the downloaded tracking code just before the closing tag and click "Update File."
This method requires connecting to the server using an FTP client (e.g., Total Commander). Locate the active theme directory on your website (path: wp-content > themes > active_theme_name) and locate the header.php file. After editing it and pasting the code before the tag, you'll need to overwrite the file on the server.
Yes, this is often the most convenient method for those without technical knowledge. Instead of modifying the source code (which carries the risk of overwriting it when updating the theme), simply install and activate one of the free integration plugins (e.g., Site Kit by Google or another SEO/analytics plugin) and go through a simple setup to connect your website to your Analytics account.
Google Analytics is a basic, free tool that allows you to measure website popularity, user traffic, and the effectiveness of marketing activities. Placing the tracking code is a necessary first step to begin collecting analytical data about your WordPress-based website.
Summary
The above article covers the following topics:
- The Google Analytics tracking code can be implemented in WordPress in three ways: through the theme editor (by pasting the code into header.php before the tag ), via FTP access to the server, or using the Google Analytics by MonsterInsights plugin. After installation, data is collected for 24-48 hours.