Where is the Google Analytics Tracking Code?

Cody Schneider8 min read

Trying to add Google Analytics to your website but can't seem to find that all-important tracking code? You're in the right place. Getting this small piece of code installed correctly is the first step to understanding who your visitors are and what they do on your site. This article provides a straightforward, step-by-step guide to locating your tracking code for both the latest Google Analytics 4 and the older Universal Analytics (UA).

What Exactly Is the Google Analytics Tracking Code?

Before we jump into finding it, let's quickly clarify what it is. The Google Analytics tracking code is a unique snippet of JavaScript that you install on your website. Its job is to watch for user activity - like page views, clicks, and how long someone stays on a page - and send all that information back to your Google Analytics account.

Think of it as a dedicated census taker for your website. It sits discreetly on every page and reports back on the who, what, and where of your website traffic. Without this code, your Google Analytics reports would be completely empty.

You'll encounter two main identifiers associated with this code, which can be a bit confusing:

  • The GA4 Measurement ID (Looks like G-XXXXXXXXXX): This is the new standard. It's part of the global site tag (gtag.js) and is what you'll use for any new Google Analytics properties.
  • The Universal Analytics Tracking ID (Looks like UA-XXXXXXXX-X): This is the identifier for the older, now-deprecated version of Google Analytics. Universal Analytics stopped processing new data in July 2023, but you might still need to find this ID if you're working with an older site or migrating historical data.

For any new setup, you will be using a GA4 Measurement ID.

Finding Your GA4 Measurement ID & Google Tag

If you set up Google Analytics recently, you have a GA4 property. Follow these steps to find your Measurement ID and the full JavaScript snippet.

Step-by-Step Guide to Locate Your GA4 Code

  1. Log in to Google Analytics: Head over to the Google Analytics homepage and sign in to your account.
  2. Navigate to Admin: Look for the gear icon labeled "Admin" in the bottom-left corner of the screen and click on it.
  3. Go to Data Streams: You'll see two columns: 'Account' and 'Property'. In the 'Property' column, click on "Data Streams." A data stream is simply a source of data for your analytics, like your website or a mobile app.
  4. Select Your Web Stream: You should see your website listed as a data stream. Click on it to open its details.
  5. Find Your Measurement ID: At the top right of the stream details page, you'll see your "Measurement ID." It will be in the format G-XXXXXXXXXX. If a plugin or CMS integration only asks for an ID, this is what you need.
  6. View the Full Tag Snippet: To get the full piece of JavaScript, scroll down and click on "View tag instructions" under the "Google tag" section. This will open a new panel where you can choose to "Install manually."
  7. Copy the Google Tag: You'll now see the full JavaScript snippet (gtag.js). Use the copy icon next to the code box. This is the code you will paste into your website's HTML.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YOURMEASUREMENTID"></script>
<script>
  window.dataLayer = window.dataLayer || [],
  function gtag(){dataLayer.push(arguments),}
  gtag('js', new Date()),

  gtag('config', 'G-YOURMEASUREMENTID'),
</script>

Finding Your Universal Analytics Tracking ID (For Legacy Properties)

If you're managing an older site or just need to reference your old Universal Analytics ID, you can still find it. Remember, these properties stopped collecting data on July 1, 2023.

Step-by-Step Guide to Locate Your UA Code

  1. Log in and Go to Admin: As before, sign in to Google Analytics and click the "Admin" gear icon in the bottom-left.
  2. Select Your UA Property: This is the most important step. At the top of the 'Property' column, there's a dropdown menu. Click it and make sure you select the property that has a "UA-" prefix in its ID. GA4 properties will just show a string of numbers.
  3. Click 'Tracking Info': Once the correct UA property is selected, look for "Tracking Info" in the 'Property' column. Click on it to expand the menu.
  4. Select 'Tracking Code': From the expanded menu, click on "Tracking Code."
  5. Find Your ID and Code: On this page, you'll see your Tracking ID (formatted as UA-XXXXXXXX-X) displayed prominently. Below it, you'll find the full Global Site Tag snippet that you can copy.

What To Do With Your Tracking Code

Okay, now you have your code. What's next? You need to add it to every page of your website. Here are the most common ways to do that.

1. Manual Installation

For this method, you need to be comfortable editing your website's HTML. The goal is to copy the entire JavaScript snippet and paste it into the <head> section of your website's HTML file, just after the opening <head> tag. If your site has multiple template files, you'll need to find the main header file where it will be applied to every page.

Be careful: Editing your theme's code can sometimes break things if not done correctly. It's always a good idea to back up your files before making changes.

2. Using a CMS Integration or Plugin

This is the easiest route for most people. Almost all modern website platforms have a built-in way to add Google Analytics.

  • WordPress: You can use a dedicated plugin like Google Site Kit, SEOPress, or MonsterInsights. These plugins typically just ask for your Measurement ID (G-XXXXXXXXXX), and they handle the rest. No code editing is required.
  • Shopify: Navigate to Online Store → Preferences. You'll find a section for Google Analytics where you can paste your entire Google tag snippet. Shopify makes this very simple.
  • Squarespace: Go to Settings → Advanced → Code Injection. There's a 'Header' box where you can paste the full tracking snippet.
  • Wix: Head to Marketing & SEO → Marketing Integrations. Select Google Analytics, click connect, and follow the prompts to add your Measurement ID.

3. Using Google Tag Manager (GTM)

For those who want more control and flexibility, Google Tag Manager is the best approach. GTM is a free tool that acts as a container for all your marketing and analytics tags. Instead of adding multiple code snippets to your site (Google Analytics, Facebook Pixel, etc.), you just add the GTM container code once. Then, you manage all your other tags from the GTM interface.

Inside GTM, you would create a new "GA4 Configuration" tag and simply paste your Measurement ID into the designated field. This is the industry-standard method and is highly recommended as you get more serious about analytics.

How to Verify Your Tracking Code is Working

After you’ve added the code, you need to make sure it's working. Don't just assume it is!

  • Check the Real-Time Report: The quickest method is to go to your Google Analytics report. On the left menu, click Reports → Real-Time. Now, open your website in a new browser tab or on your phone. Within a minute or two, you should see yourself appear as a visitor in the Real-Time report. If you do, it’s working!
  • Use Browser Developer Tools: Right-click anywhere on your website and select "View Page Source" or "Inspect". A panel with your site's code will open. Use Ctrl+F (or Cmd+F on Mac) and search for gtag.js or your G- Measurement ID. If it appears in the code, it's installed.
  • Try the Google Tag Assistant: The Google Tag Assistant Companion is an official Chrome extension that helps you see if your Google tags are firing correctly. It can provide more detailed diagnostic information if things aren't working as expected.

Final Thoughts

Finding and installing your Google Analytics tracking code is the foundational step toward making data-informed decisions for your business. By following the steps above, you can confidently locate the correct code for your property, get it installed, and verify that it’s collecting data on site activity.

While getting the tracking code set up is the first step, the real goal is to turn that data into useful insights without spending your entire day in multiple analytics platforms. We designed Graphed to solve exactly this problem. Instead of wrestling with complex reports, you can connect sources like Google Analytics in just a few clicks and use natural language to create real-time dashboards and reports. Just ask, "Show me my top landing pages by sessions and conversion rate this month," and we'll build the report for you instantly, allowing you to get answers in seconds, not hours.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.