Where to Copy Google Analytics Code?

Cody Schneider7 min read

To start tracking your website’s performance, you need to add a sliver of code from Google Analytics to your site. This code, sometimes called the GA4 tracking tag, is what makes the magic happen, collecting valuable data about your visitors. This article will show you exactly where to find your Google Analytics tracking code and the right way to install it.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

What is the Google Analytics Tracking Code?

The Google Analytics tracking code is a unique snippet of JavaScript that you install on your website. When a visitor lands on a page, this script runs in their browser. It gathers anonymous information about their session - like which page they’re on, how they got there, and what device they're using - and sends it all back to your Google Analytics account.

Every Google Analytics 4 property has a unique "Measurement ID" that looks like G-XXXXXXXXXX. This ID is part of the larger tracking code snippet and serves as the destination address for your website's data.

You can think of it like this:

  • The Measurement ID (G-...) is like your P.O. box number. It’s a simple identifier. Many website builders and plugins will only ask for this ID.
  • The full JavaScript code snippet (known as the global site tag or gtag.js) is the entire mailing label and postage. It contains the instructions and the destination for sending the data. You’ll use this full snippet for manual installations on custom-coded sites.

Step-by-Step: How to Find Your GA4 Tracking Code

Finding your code involves navigating a few menus inside Google Analytics. Follow these steps, and you’ll have it copied in a minute or two.

Step 1: Sign in to Google Analytics

First things first, head over to analytics.google.com and sign in with your Google account. If you have multiple accounts, be sure to select the one associated with the website you want to track.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 2: Go to the Admin Section

Once you’re in your GA4 dashboard, look for the gear icon labeled "Admin" in the bottom-left corner of your screen. Click it to open the administration panel.

Step 3: Select Your Account and Property

The Admin page has two main columns: "Account" and "Property."

  • In the "Account" column, choose the account that contains your website's property.
  • In the "Property" column, select the specific GA4 property you're working with. Check that the name matches your website.

Step 4: Click on 'Data Streams'

With the correct property selected, look for the "Data Streams" option within the "Property" column. This is where Google manages the sources of data flowing into your property, such as your website or mobile app.

Step 5: Select Your Web Data Stream

After clicking "Data Streams," you'll see a list of streams set up for this property. Most likely, you will have one stream for your website, labeled under the "Web" platform. Click on it to open its details.

Step 6: Copy Your Measurement ID or Full Tracking Code

You’re now on the Web stream details page. This is the final destination!

To Copy the Measurement ID:

Your Measurement ID (e.g., G-TCB2YDDNER) is displayed prominently in the top right. Click the copy icon next to it. This is all you need if you're using a website builder like Shopify or a WordPress plugin that has a dedicated Google Analytics integration field.

To Copy the Full Google Tag Snippet:

If you need to install the code manually, scroll down to the section titled "Google tag" and click on "View tag instructions".

A new page will load. Select the "Install manually" tab. Here, you'll see the full JavaScript code snippet. Click the copy icon to copy the entire block of code to your clipboard.

The code will look something like this:

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

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

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Where to Paste the Google Analytics Code on Your Website

Now that you have the code, you need to put it on your website. The most important rule is that the tracking code must be placed in the <head> section of every single page you want to track. Placing it in the header ensures it loads first, allowing it to capture data even from visitors who bounce away quickly.

How you do this depends on the platform your website is built on.

For WordPress Sites

On WordPress, you have a few easy options:

  • Use an Integration Plugin: This is the simplest method. Plugins like Site Kit by Google (Google's official plugin) or GA Google Analytics allow you to connect your account and automatically add the code. Often, they only require you to paste your Measurement ID, not the full code snippet.
  • Header and Footer Scripts Plugin: If your theme doesn't have a spot for scripts, you can use a plugin like "WPCode – Insert Headers and Footers." Simply paste the entire gtag.js snippet into the "Header" section of the plugin.
  • Theme's header.php file (Advanced): For advanced users, you can edit your theme's <code>header.php</code> file. It's best to use a child theme for this so your changes aren't lost when the parent theme updates. Paste the code snippet right before the closing <head> tag.

For Shopify Stores

Shopify makes this incredibly easy. There's no need to edit code.

  1. From your Shopify Admin, go to Online Store > Preferences.
  2. Scroll down to the "Google Analytics" section.
  3. Paste just your Measurement ID (G-...) into the box and click "Save."

Shopify will handle the rest, adding the correct tracking code to all of your store’s pages, including the checkout process.

For Squarespace, Wix, or Other Website Builders

Most modern website builders have a built-in field for Google Analytics integration.

  • Squarespace: Go to Settings > Advanced > External API Keys. Paste your Measurement ID here.
  • Wix: Go to Marketing & SEO > Marketing Integrations. Under Google Analytics, click "Connect" and follow the simple on-screen instructions, which will ask for your Measurement ID.

Always look in your builder's "Settings," "Integrations," or "Marketing" section for a Google Analytics option before trying to add the code manually.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

For a Custom HTML Website

If you've coded your website yourself, you'll need to do it the old-fashioned way. Open up every HTML file for your website and paste the full gtag.js code snippet just before the closing <head> tag. A smarter way is to use a server-side include or template file for your header so you only have to paste the code in one location.

How to Verify Your Installation is Working

After installing the code, you need to make sure it's working properly. Don't skip this step!

  • Check Real-Time Reports: This is the quickest and easiest way. In your Google Analytics account, go to Reports > Realtime. Now, open your website in a different browser tab or on your phone. Within a minute or two, you should see yourself pop up as a visitor on the Realtime-overview map. If you see activity, it's working!
  • Use Google Tag Assistant: Go to tagassistant.google.com, enter your website URL, and click "Connect." A new tab with your website will open with a debug window. If it shows that your Google tag (with your Measurement ID) fired successfully, you're good to go.
  • Use Browser Developer Tools: For a more technical check, you can open your browser's developer tools (usually by pressing F12), go to the "Network" tab, and then visit your site. In the filter box, type "collect". If you see a successful request to a URL containing google-analytics.com, the tag is sending data.

Final Thoughts

Finding your Google Analytics code begins in the Admin panel, under Data Streams, where you can copy either your Measurement ID or the full tracking snippet. Pasting this into the head section of your site, usually via a plugin or built-in platform integration, connects your site to GA4, allowing you to start collecting valuable visitor data.

Once you’ve installed the code, the next challenge is turning that mountain of data into actionable insights without spending hours getting lost in GA4's complex interface. With Graphed, we make that part incredibly simple. Just connect your Google Analytics account, and then create custom reports and dashboards using plain English. Instead of learning to build funnel reports manually, you can just ask, "Show me a funnel report for started checkout to purchase" and get an answer instantly. This helps you skip the heavy lifting and focus on what the data actually means for your business.

Related Articles