GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (2024)

When you buy something through one of the links on our site, we may earn an affiliate commission.

Looking for the GA4 tracking code? Or maybe you're unsure where to place it on your site?

No problem.

In this post, we answer these questions and more, so you can track your Google Analytics stats for your business.

The short answer: The GA4 tracking code is under admin > Data Streams > view tag instructions > and the install manually tab.

From here, you'll see the code that needs to be added inside your website head tags.

But what if you don't want to use the manual approach? And what are header tags anyway?

Keep reading as I show you how step-by-step.

Contents

  • Where is the GA4 Tracking Code in Google Analytics?
  • What's the Difference Between Tracking Code and Measurement ID
  • What Does the GA4 Tracking Code (or Measurement ID) Do Exactly?
  • How to Add Your GA4 Tracking Code to Your Site
    • 1. Manual Method
    • 2. Using Google Tag Manager
    • 3. With a WordPress Plugin
  • Conclusion

Where is the GA4 Tracking Code in Google Analytics?

First off, you need to make sure you have a GA4 property and data stream for your website.

Here's how to add one.

Go to analytics.google.com and log in to your Google account. If you need to create an account, you'll see this first:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (1)

Fill in the details about your website in the fields and click next:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (2)

Answer a few questions about your business:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (3)

Then click on Web to create your Data Stream:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (4)

Enter your Website URL and Stream Name, and click Create Stream. You can leave the enhancement measurement section as it is:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (5)

The next screen is where you'll find your GA4 Measurement ID and Tracking code:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (6)

What if you already have a Google Analytics account and data stream but can't find it?

Here's exactly where to look.

From the Google Analytics 4 dashboard, hover over the gear icon and click on it to access the settings:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (7)

Then click on Data Streams setting:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (8)

Click the Data Stream:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (9)

On the Data Stream Details page, you see your GA4 Measurement ID:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (10)

But if you need the full tracking code, scroll down on this page and click View Tag Instructions:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (11)

Click on the Install Manually tab, and you'll see the tracking code:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (12)

What's the Difference Between Tracking Code and Measurement ID

In GA4, the difference between "GA4 tracking code" and "Measurement ID" is the terminology, as they both mean the same thing.

The confusion comes from Universal Analytics because it used to be called Tracking ID. Now in Google Analytics 4, it's called Measurement ID.

But what about the manual Google Tag?

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (13)

The code above is called the Google Tag (or GTag) which is code that you add manually to the HTML of your website.

However, you don't always need to use this code if your website supports the GA4 Measurement ID.

More on this later.

What Does the GA4 Tracking Code (or Measurement ID) Do Exactly?

The GA4 tracking ID or Measurement ID actually does quite a lot in the background.

You know you're looking at the measurement ID for GA4 because it starts with the letter "G," followed by some characters:

"G-XXXXXXXXXX"

When you add this code to your site, it creates a connection between Google Analytics 4 and the activity on your website, which gets stored in your dashboards and reports.

Here's exactly what the measurement ID does:

  • Identifies data streams: The measurement ID acts as a unique identifier for each data stream in your property, linking user interactions to the correct data stream in GA4.
  • Data collection and tracking: It gets embedded in the tracking code and placed on your website or app. The code then collects and sends data back to GA4 about user interactions, events, and conversions.
  • Integrates with GTM: Google Tag Manager is another tool by Google to help manage tags and provide more advanced data collection. You can integrate GA4 with GTM to keep tags more organized and collect more granular metrics.
  • Distinguishes from property ID: This means you can have more than one measurement ID for one property. For example, tracking an online store, a blog, and a mobile app.

How to Add Your GA4 Tracking Code to Your Site

Now you know where to find the GA4 tracking code, it's time to add it to your site. How you add it will depend on the platform you're using.

Plus, there are a few methods, so let's break each of them down.

1. Manual Method

The manual method is where you take that scary-looking code and paste it into the HTML of your website.

This is usually the way developers do it because it provides optimal placement for load time and more tracking customizations.

Here's what to do.

Follow the steps above and highlight this code:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (14)

Then, find the file on your website with the <head> tag. In WordPress, this is the header.php file in your theme's folder.

Just make sure you are editing a child theme first, otherwise, the changes will be overwritten when the theme updates.

Copy the code and paste it immediately after the <head> tag:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (15)

If you're using Shopify, the file to edit is called theme.liquid, which can be found in Online Store > Themes, Customize, then Edit Code.

That's it! Save the file, and you will start seeing data show up within 24 hours, sometimes much sooner.

2. Using Google Tag Manager

The next method is to use Google Tag Manager, which is similar to the manual method, but you're adding the code from GTM to your site instead of the GA4 code.

Here is how to do it.

Go toGoogle Tag Managerand click onStart for free:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (16)

Create an account and enter your details for your website:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (17)

On the next screen, you'll see this popup:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (18)

This is the code you'll add to your site instead of the GA4 code.

Copy the code in the top box and paste it immediately under the <head> tag:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (19)

And the code in the bottom box goes directly under the <body> tag:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (20)

Save your file and then go back to Google Tag Manager.

To test if the Tag is working on your site, click the Preview button in GTM:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (21)

This will open up a new window to see if the connection can be made. If everything is working, you'll see this popup box:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (22)

The last step is to add your Measurement ID from Google Analytics to Tag Manager.

Copy the code here:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (23)

Then, create a new Tag inside Google Tag Manager:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (24)

Click onTag Configuration, thenGoogle Tag:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (25)

Paste your measurement ID in theTag ID field:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (26)

Click theTriggering boxand chooseAll Pages:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (27)

Give your tag a title and click onSave:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (28)

Test the connection again and then save your configuration:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (29)

Name the GA4 configuration and clickPublish:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (30)

That's it!

3. With a WordPress Plugin

The final way to add the Google Analytics tracking ID to your site is using a WordPress plugin.

But which plugin do you use? I answer that in my post on the best Google Analytics plugins for WordPress.

In that post, I list two types of plugins. One just adds the tracking code and the other adds the tracking code and displays your GA4 metrics in your WordPress dashboard.

Here I'll show you how to add MonsterInsights because it gives some basic metrics in your dashboard for free and you can upgrade later if you want.

Go to your plugins, add new and search for MonsterInsights:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (31)

Then click on Launch the Wizard!

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (32)

Choose your business type:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (33)

Click Connect MonsterInsights:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (34)

Click Continue & Connect to Google:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (35)

Choose your Google Account, click continue on the next page, and then Allow:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (36)

Select your GA4 property from the dropdown:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (37)

Configure your GA4 settings on the next page:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (38)

You'll be directed to the MonsterInsights dashboard, where you can see your metrics like website visitors:

GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (39)

Not only does MonsterInsights display your website metrics, but it also adds the GA4 tracking code to your site so that Google Analytics can collect the data.

That's it!

Conclusion

Finding the GA4 tracking code and adding it to your site can be a daunting process. But, this article has certainly shed some light.

Now that you know how it's done, you can track the performance of your website and make any needed changes.

What should you track? Check out our post on engagement metrics to find out.

Related Posts

I Just Bought a Mom Blog

Behind the Scenes of a Content and Link Building Campaign with Mark Mars from Niche Website Builders

9 Best AdThrive Alternatives To Monetize Your Blog

How to Earn Money on Facebook: $500 Every Day With 9 Great Ways!

13 of The Best All-In-One Marketing Platforms To Help Grow Your Business

Want to learn step-by-step how I built my Niche Site Empire up to a full-time income?

Yes! I Love to Learn

Learn How I Built My Niche Site Empire to a Full-time Income

  • How to Pick the Right Keywords at the START, and avoid the losers
  • How to Scale and Outsource 90% of the Work, Allowing Your Empire to GROW Without You
  • How to Build a Site That Gets REAL TRAFFIC FROM GOOGLE (every. single. day.)
  • Subscribe to the Niche Pursuits Newsletter delivered with value 3X per week
GA4 Tracking Code: Where to Find it and How to Add it to Your Site? (2024)

References

Top Articles
Latest Posts
Article information

Author: Mr. See Jast

Last Updated:

Views: 6062

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Mr. See Jast

Birthday: 1999-07-30

Address: 8409 Megan Mountain, New Mathew, MT 44997-8193

Phone: +5023589614038

Job: Chief Executive

Hobby: Leather crafting, Flag Football, Candle making, Flying, Poi, Gunsmithing, Swimming

Introduction: My name is Mr. See Jast, I am a open, jolly, gorgeous, courageous, inexpensive, friendly, homely person who loves writing and wants to share my knowledge and understanding with you.