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