View Categories

Adding Google Analytics

The Google Analytics tracking script enables you to monitor and analyze visitor behavior and gain valuable insights into user interactions such as page views, demographics, traffic sources, and popular content.

Utilizing these insights enables you to make data-driven decisions, enhance user experience, optimize marketing efforts, and maximize conversions, regardless of the size of your website. This tool is indispensable for tracking performance and elevating your online presence.

Google Analytics can be a royal pain for many website owners. This is why we’ve added various options (5 methods) for adding Google Analytics tracking code to your website. It can be done in a few steps and different ways; here’s how you can easily add the tracking code:

What Is Google Analytics

Google Analytics 4 is the latest version of Google Analytics. Here’s what the tracking code looks like for GA4:

<!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'GA_TRACKING_ID'); </script>

Replace ‘GA_TRACKING_ID’ with your actual Google Analytics Tracking ID, which will look something like G-XXXXXXXXXX. This script should be placed in your website’s <head> section to ensure it loads early on every page.

To find the code, log in to your Google Analytics account, go to Admin > Data Streams under the property you want to track, and click on the data stream. You’ll find the Measurement ID (in the G-XXXXXXXX format).

Adding Google Analytics In Customizer

  • Go to Google Analytics to grab your already set up code, then go to Appearance > Customize > General > Custom Scripts. You’ll see fields for Header Script, Before </body> Script, and Footer Script.
  • Go to Google Analytics to grab your already set up code, then go to Appearance > Customize > General > Custom Scripts. You’ll see fields for Header Script, Before </body> Script, and Footer Script.
  • Copy your Google Analytics tracking code (this should be the JavaScript snippet that Google Analytics provides).
  • Paste the code in the Header Script section. This ensures that the Google Analytics script loads on all pages.
  • Once you’ve pasted the tracking code, click the Publish button to save the changes.

Adding Google Analytics Using PHP

If you’re using a child theme, you can manually insert the Google Analytics tracking code in the child theme’s header.php or functions.php file.

  • Go to Appearance > Theme File Editor.
  • Choose header.php (or functions.php if you prefer an action hook).
  • Paste the Google Analytics code just before the </head> tag in the header.php file.
  • Click Update File to save the changes.

This method is more manual but ensures full control over where the script is placed. You can also add all your codes here, such as Pinterest, Bing, Yandex, and more.

Adding Google Analytics Using Elements

If you have Kadence Pro, you can use Hooked Elements to inject the Google Analytics code directly where you want it.

  • Go to Appearance > Kadence > Elements.
  • Click on Add New Element, and select the HTML type.
  • Paste your Google Analytics code in the HTML editor.
  • In the Element Settings panel, set the location where this hook should be applied, such as Before Header or After Header to ensure it applies site-wide.
  • Publish the element once you’ve added the code and configured the display settings.

You can add all your codes here, such as Pinterest, Bing, Yandex, and more.

Adding Google Analytics Using A Plugin

You can use a plugin if you prefer not to touch any code or want a more robust option for Google Analytics. This is by far the easiest solution. Although we don’t recommend plugin overload, this free forever Site Kit by Google plugin has zero negative impact on your website, which is why we recommend it in our Resources.

This plugin takes the guesswork out of setting up your code, finding it, and adding it. It does the hard work for you! It also gives you additional analytics tools on a dedicated dashboard.

  • Go to Plugins > Add New.
  • Search for Site Kit by Google.
  • Once the plugin is installed, follow the on-screen instructions to add your Google Analytics tracking code.

You will need to add all your other codes, such as Pinterest, Bing, Yandex, and more, using one of the above methods.

NOTE: If some of these options are unavailable, you most likely do not have the Kadence Pro installed.

Join The Party For Fun Updates & Big Discounts!