2 minutes of reading

How to Implement Google Analytics Tracking Code in WordPress? Installation Methods (Plugin, Code, FTP)

How to Implement Google Analytics Tracking Code in WordPress? Installation Methods (Plugin, Code, FTP) - Image #1

How to Implement Google Analytics Tracking Code in WordPress? Installation Methods (Plugin, Code, FTP) - Image #2

Contents

You are now reading:

How to Implement Google Analytics Tracking Code in WordPress? Installation Methods (Plugin, Code, FTP)

Close

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.

Google Analytics WordPress 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."

google analytics wordpress tracking code 2

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)

Fill out the form and schedule a call with an expert

We'll get to know your business and prepare a personalized quote for the optimal marketing mix. Completely free.

The controller of your personal data is Verseo, a limited liability company with its registered office in Poznań, at ul. Węglowa 1/3.

About Verseo

The Company's registered office is located in Poznań. The Company is entered in the Register of Entrepreneurs maintained by the District Court for Poznań – Nowe Miasto and Wilda in Poznań, 8th Commercial Division of the National Court Register, under KRS number: 0000910174, Tax Identification Number (NIP): 7773257986. You can contact us by mail at the address provided above or by email at: ochronadanych@verseo.pl

You have the right to:

  1. access to your data,
  2. rectification of your data,
  3. request deletion of data,
  4. processing restrictions,
  5. object to the processing of personal data,
  6. transfer of personal data,
  7. withdrawal of consent.

If you believe that we are processing your data contrary to legal requirements, you have the right to lodge a complaint with the supervisory authority – the President of the Personal Data Protection Office.

We process your data for the purpose of:

  1. handling your inquiry, pursuant to Article 6(1)(b) of the General Data Protection Regulation (GDPR);
  2. marketing purposes consisting in the promotion of our goods and services and ourselves in connection with the consent you have granted, pursuant to Article 6(1)(a) of the GDPR;
  3. securing or pursuing possible claims in connection with our legitimate interest, pursuant to Article 6(1)(f) of the GDPR.

Providing your data is voluntary . However, without it, you will not be able to send us a message, and we will not be able to respond to you.

We may transfer your data to trusted recipients:

  1. providers of tools for: website traffic analysis, sending marketing information.
  2. entities responsible for hosting (storing) the website and personal data.

We will process your data for the period of:

  1. necessary to achieve the specific purpose for which they were collected, and after its expiry for the period necessary to secure or pursue any claims
  2. in the case of data processing based on consent until its withdrawal. Withdrawal of consent does not affect the lawfulness of processing prior to withdrawal.

We do not process personal data in a way that would involve making solely automated decisions about you. More information regarding the processing of personal data can be found in our Privacy Policy.

google analytics wordpress tracking code 3

Then we paste our Analytics code before the closing header tag

google analytics wordpress tracking code 4

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.)

how to install google analytics in wordpress

Then we edit the header.php file

Installing Google Analytics in WordPress

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.

Installing Google Analytics in WordPress

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.

Installing Google Analytics in WordPress

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

Installing Google Analytics in WordPress

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

Google Analytics WordPress

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

Google Analytics WordPress

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.

Google Analytics WordPress

* 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:

Google Analytics WordPress

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.