Adding Google Analytics tracking Code in WordPress site

Adding Google Analytics tracking Code in Wordpress site

Adding Google Analytics tracking code in WordPress site can be achieved through two distinct methods. Each approach offers flexibility based on your preferences. Here is a breakdown of these methods:

 Adding Google Analytics tracking Code in WordPress site in header.php

This method involves inserting the Google Analytics Tracking Code directly into your website’s code, specifically within the “header.php” file.

To proceed:

  1. Access your WordPress Dashboard. Assuming you already have a WordPress website. If not, you can easily create one using Cloudways WordPress hosting.
  2. Navigate to Appearance → Editor.
  3. Select the “header.php” file to edit its code.
  4. Copy the “Tracking Code” provided by Google Analytics.
  5. Paste the code just before the </head> tag in the header code section.
  6. Save the changes.

Please note, after implementing the code, it may take up to 24 hours for the installation to be fully active and start registering data.

Add Google Analytics code with GA Google Analytics plugin


Read Also: Getting High Adsense CPC Rate with Tools


Adding Google Analytics tracking Code in WordPress site using a WordPress Plugin

If your theme limitations prevent you from using the primary method, employing a plugin to install Google Analytics is an effective alternative.

Here are steps outlining the installation using oneof the most reliable plugins available:

The GA Google Analytics plugin is a robust, well-constructed tool for this purpose. Follow these steps to integrate GA into your WordPress site seamlessly:

  1. Access your WordPress Dashboard.
  2. Navigate to Plugins → Add New.
  3. In the search box, enter “GA Google Analytics.” As the plugin supports GA4, it seamlessly integrates with your WordPress site.
  4. Locate and select the “Install Now” button, followed by “Activate” once installation completes.
  5. Upon activation, configure the plugin settings.
  6. Go to Dashboard → Settings → Google Analytics.
  7. Click on Plugin Settings.
  8. Copy and paste the “Tracking ID” from the “Google Analytics Tracking Code” page.
  9. Ensure that the “Universal Analytics / analytics.js” and “Include tracking code in page head (via wp_head)” boxes are checked. These settings are crucial for setting up Google Analytics on the WordPress website.
  10. Save changes by clicking the “Save Changes” button.

This method provides a straightforward way to incorporate Google Analytics into your WordPress site, circumventing theme restrictions.