Esumo
Narzędzia

How to effectively integrate analytics tools with WordPress?

4 lutego 2026

Why is analytics crucial for website development?

The answer is simple, so we’ll address this question right at the beginning of this post. Analytics is an invaluable tool in the fight for customer attention in a world where every click and page scroll can translate into conversion. To effectively optimize analytical activities on WordPress, it’s crucial to start with clearly defined goals. They should align with our website’s objectives – whether we’re focusing on sales, increasing the number of subscribers, or building engagement. When we know our goals, we can appropriately select tools that will provide data on traffic, user behavior, their preferences, and the effectiveness of individual content.

Consistent monitoring of conversion rates, page views, and bounce rates allows for better understanding of user engagement and site performance. Through analysis of user interactions with our site, we can discover important behavioral patterns. For example, understanding how users navigate the site allows us to identify which content is most attractive and where problems may occur that cause engagement drops. Thanks to such data, we can effectively optimize our WordPress site’s design and content, adapting it to user needs and striving to achieve intended goals.

Step by step: How to integrate analytics tools with WordPress?

Integrating Google Analytics 4 with WordPress

Google Analytics 4 is the latest version of the popular website traffic analysis tool that allows tracking user interactions and provides detailed information about their behaviors. GA4 is based on an event tracking model, which enables monitoring actions such as clicks, page scrolls, making purchases, or filling out forms. Thanks to advanced analysis features such as trend forecasting and integrated user reports, GA4 makes it easier to make business decisions based on real data.

Manual addition of global site tag directly in the template (in the header.php file)

Step 1: Log in to your Google Analytics 4 account and select the appropriate property.

Step 2: Obtain the GA4 tracking code:

Go to the Admin section (gear icon in the lower left corner).

In the Data collection and modification column, select Data streams. Click on your website, then copy the MEASUREMENT ID from the Stream details section.

Step 3: Log in to your WordPress site’s admin panel, then in the menu on the left side select Appearance -> Theme File Editor.

Step 4: In the Theme Files field on the right side, find the header.php file. The code editor will open.

Step 5: In the header.php file, find the section. Paste the copied GA4 measurement ID just before the closing tag.

Step 6: After pasting the code, Update the file to save changes to the file. After completing these steps, your WordPress site is integrated with Google Analytics 4.

When choosing this option, keep in mind that updating the template will overwrite the changes you made. In case of an update or template change, the code will need to be added again.

WordPress integration using the GA Google Analytics plugin

Step 1: Log in to your WordPress site’s admin panel, then in the menu on the left side select Plugins -> Add New.

Step 2: Find the GA Google Analytics plugin and click the Install button.

Step 3: After installation is complete, activate the plugin by clicking the Enable button. After activation, a list of all installed plugins will be displayed.

Step 4: Go to the plugin settings by clicking Settings under its name. Then click on the Plugin Settings tab.

Step 5: In the GA Tracking ID field, enter your Google Analytics 4 measurement ID (format: G-XXXXXXX). To do this, copy your identifier from your Google Analytics 4 account – the complete process of obtaining the tracking code is described in step 2 of subsection a) Manual addition of global site tag directly in the template.

Step 6: In the Tracking Method field, select the tracking method you want to use: Global Site Tag.

Step 7: Click the Save changes button to complete the configuration. Now Google Analytics will track traffic on your WordPress site.

Integrating Google Search Console with WordPress

Google Search Console is a free tool offered by Google that helps website owners monitor and improve their site’s visibility in search results. GSC provides information about keywords for which the site appears, indexing errors, and SEO-related issues. Thanks to reports and suggestions from Google Search Console, users can optimize their pages for search engines, which increases the chances of achieving higher positions in search results and attracting more traffic.

How to add a WordPress site to Google Search Console?

Step 1: Log in to your Google account and open Google Search Console. Click the Add property button.

Step 2: Add your website. Two methods are available for adding a property:

  • Domain: allows tracking the entire domain (including subdomains).
  • URL prefix: allows tracking a specific URL address.

Step 3: Verify ownership (Verify ownership). GSC requires confirmation that you have rights to manage the site. You can do this in several ways:osobów:

In case of adding a property by domain:

  • Method 1: Verification using TXT record Log in to your domain provider.
    1. Log in to your domain provider.
    2. Copy the displayed TXT record to the domain’s DNS configuration.
    3. Without closing the GSC configuration window, go to your domain provider’s panel to add a new record in the domain’s DNS zone.
    4. Click the Verify button.

In case of adding a property by URL prefix:

  • Method 1: Verification using HTML file (recommended)
    1. Download the HTML file generated by Google.
    2. Upload the file to the main domain directory. To do this, log in to your WordPress site’s admin panel, then in the menu on the left side select Appearance -> Theme File Editor.
    3. Transfer the HTML file to the server, to the main site directory using a file manager or FTP.
    4. After uploading the file, return to Google Search Console and click the Verify button.
  • Method 2: Verification using HTML tag
    1. Google will display HTML code that needs to be inserted in the section on your site.
    2. Log in to your WordPress site’s admin panel, then in the menu on the left side select Appearance -> Theme File Editor.
    3. In the Theme Files field on the right side, find the header.php file. The code editor will open.
    4. In the header.php file, paste the code in the section before the first section.
    5. After pasting the code, click the Update File button.
    6. Return to Google Search Console and click the Verify button.
  • Method 3: Verification using Google Analytics or Google Tag Manager
    1. If your site is already connected to Google Analytics or Google Tag Manager, you can use these tools to verify the site.
    2. To do this, log in to your Google account that has permissions to edit the given service in Google Analytics and select the service for verification.
    3. On the site verification details page, select Google Analytics and click the Verify button.

Step 4: After correctly completing the above steps, Google Search Console will display a successful verification message.

Step 5: After verification, go to the Sitemaps tab and add the URL of your sitemap. Regularly check reports on site status, indexing errors, and analyze keywords for which your site appears.

Integrating Hotjar with WordPress

Hotjar is an analytics tool that enables analysis of user experiences on a website. Thanks to features such as heatmaps, session recordings, and user surveys, Hotjar allows you to see how users interact with the site, where they focus their attention, and where they may encounter difficulties. It’s a valuable tool for WordPress site owners who want to understand their users’ behaviors and optimize the site for better UX and higher conversions.

Manual addition of code directly in the template (in the header.php file)

Step 1: Log in or register on the Hotjar platform and configure an account for your website by entering its name and URL address.

Step 2: Go to the Sites tab. In the Tracking column, click Install tracking code for the site you want to track. Copy the generated tracking code from the Hotjar panel.

Step 3: Log in to your WordPress site’s admin panel, then in the menu on the left side select Appearance -> Theme File Editor.

Step 4: In the Theme Files field on the right side, find the header.php file. The code editor will open.

Step 5: In the header.php file, paste the copied tracking code between the and tags in your site’s code. After pasting the code, Update the file to save changes to the file.

Step 6: After adding the Hotjar tracking code to the site, wait a few minutes for Hotjar to verify the correctness of its installation. The verification status can be checked in the Sites tab of the Hotjar panel.

When choosing this option, keep in mind that updating the template will overwrite the changes you made. In case of an update or template change, the code will need to be added again.

Integration using the dedicated HotJar plugin

Step 1: Create a free account on the HotJar platform by entering basic information or logging in through your Google account.

Step 2: Click the Install on a platform button, then select WordPress from the displayed list.

Step 3: Log in to your WordPress site’s admin panel, then in the menu on the left side select Plugins -> Add New. Find the Hotjar plugin and click the Install button. After installation is complete, activate the plugin by clicking the Enable button.

Step 4: In the menu on the left side, select Settings -> Hotjar, then in the Hotjar ID field, enter the ID of your Hotjar service. The service ID will be displayed in the Hotjar service panel. After entering the ID in the plugin settings, save the changes, then click the Verify installation button in the Hotjar panel. After completing the above steps, Hotjar will verify the integration correctness and start collecting data that will then be available to you.

Integrating Matomo with WordPress

Matomo is an open-source alternative to Google Analytics, offering full control over user data and their privacy. Matomo can be installed locally on your own server or used in a cloud version, which provides flexibility and security compliant with GDPR requirements and other data protection regulations.

Manual addition of code directly in the template (in the header.php file)

Step 1: Log in to the Matomo platform using an administrator account. Click the Administration button (gear icon) in the top menu.

Step 2: In the menu on the left side, select Websites -> Tracking Code. Click the JavaScript Tracking tab and select the site you want to track. Copy the JavaScript tracking code.

Step 3: Log in to your WordPress site’s admin panel, then in the menu on the left side select Appearance -> Theme File Editor.

Step 4: In the Theme Files field on the right side, find the header.php file. The code editor will open.

Step 5: In the header.php file, paste the copied JavaScript tracking code inside the section in your site’s code. After pasting the code, Update the file to save changes to the file. Your WordPress site is now configured to track visitor data using Matomo.

When choosing this option, keep in mind that updating the template will overwrite the changes you made. In case of an update or template change, the code will need to be added again.

Integration using the dedicated Matomo plugin for WordPress

The Matomo Analytics plugin installs Matomo directly in your WordPress. After installation, tracking occurs locally within WordPress. With this type of installation, data remains in your WordPress and is not transmitted externally.

Step 1: Log in to your WordPress site’s admin panel, then in the menu on the left side select Plugins -> Add New. Find the Matomo Analytics plugin and click the Install button. After installation is complete, activate the plugin by clicking the Enable button.

Step 2: Go to Matomo Analytics -> Get started and enable tracking by clicking the Enable tracking now button.

If you use ad-blocking software in your browser, it may be necessary to add an exception for your site.

Integration using the Connect Matomo plugin for tracking with a self-hosted Matomo installation

This installation works independently of WordPress and runs on a separate server. If you already have a Matomo On-Premise account or use the Matomo Cloud service, it is recommended to install the Connect Matomo plugin.

Step 1: Log in to your WordPress site’s admin panel, then in the menu on the left side select Plugins -> Add New. Find the Connect Matomo plugin and click the Install button. After installation is complete, activate the plugin by clicking the Enable button.

Step 2: In the menu on the left side, select Settings -> WP-Matomo. In the Connect to Matomo tab, from the Matomo Mode dropdown list, select the Self-hosted (HTTP API, default) option. In the Matomo URL text field, enter the Matomo URL address. In the Auth token text field, enter your Matomo authentication token. To generate the token_auth, follow these steps:

  1. Log in to Matomo.
  2. In the top menu, go to Matomo Admin.
  3. In the menu on the left side, select Personal -> Security.
  4. At the bottom of the page, click Create new token.
  5. Confirm the password to your account.
  6. Enter the purpose of this token.
  7. Select whether the token should be valid only in the case of security tasks (Matomo 5 and newer).
  8. Click the Create new token button. A newly created token will appear. Save it in a secure location because you won’t be able to see it again after you close this screen.

Step 3: Check that the Auto config checkbox is selected, then click the Save changes button. If the provided information is correct, the message „Connect Matomo is successfully connected to Matomo” will appear.

Step 4: In the Enable Tracking tab, from the Add tracking code dropdown list, select the Default tracking option. Click the Save changes button.

It is not recommended to use both Matomo Analytics and Connect Matomo plugins simultaneously, as this can lead to conflicts and incorrect tracking data.

How to maintain effective analytics integration with WordPress?

Effective integration of analytics tools with WordPress is a milestone toward better understanding and optimizing your site. In this post, we discussed detailed methods of implementing tools such as Google Analytics, Google Search Console, Hotjar, and Matomo, both using plugins and through manual code addition.

Plugins undoubtedly facilitate the entire integration process, making it quick and intuitive even for less technically advanced users. However, it’s worth remembering that an excess of plugins can lead to site performance issues and the need for regular updates to maintain security and compatibility.

On the other hand, manual integration can be a more stable and secure solution, although it requires some technical knowledge. If you don’t feel confident editing site code, using the help of an experienced specialist may be the best choice to avoid potential errors.

Regardless of the chosen method, it’s crucial to regularly monitor the operation of integrated tools and ensure that your site functions smoothly and that analytical data is accurate and useful in making decisions regarding site development.

Jakub Jadczak

Founder @ Esumo

Od 9 lat buduję markę Esumo, przekuwając pasję do technologii w skuteczne rozwiązania biznesowe. Specjalizuję się w ekosystemie WordPress oraz HubSpot, tworząc strony i narzędzia, które nie tylko świetnie wyglądają, ale przede wszystkim zarabiają na siebie. Na tym blogu dzielę się wiedzą o optymalizacji, bezpieczeństwie i nowoczesnym e-commerce, pomagając Ci poruszać się po świecie cyfrowych produktów bez zbędnego żargonu.
Free consultation

Let's talk about how we can help you

In today’s world, a professional website is a business foundation. Presence alone is however not enough – the key is technology that truly supports your goals. To see how we can help your company, we’ll assess during a free consultation.

Fill out the form and we’ll get in touch with you. During a 30-minute, free conversation, we’ll assess what strategy and technology solutions will be most beneficial for you.

 

Fill out the form