How to Add Google Analytics to Website

Cody Schneider9 min read

Knowing who visits your website, what they look at, and where they came from is the first step to making smarter decisions about your business. Google Analytics is the most popular tool for the job, and setting it up is easier than you might think. This guide will walk you through exactly how to add Google Analytics to your website, from creating an account to making sure it’s tracking correctly.

What Is Google Analytics and Why Do You Need It?

Google Analytics (GA) is a free web analytics service offered by Google that tracks and reports website traffic. Think of it as a powerful dashboard for your website. Once installed, it collects data on every person who visits, giving you invaluable insights. The current version, Google Analytics 4, is built to track users across websites and apps, focusing on the actions or "events" people take.

But why should you go through the trouble of setting it up? Because data-driven decisions beat guesswork every time. Here’s a quick look at what Google Analytics helps you do:

  • Understand Your Audience: Learn where your visitors live, what age range they fall in, and what technology they use to browse your site. This helps you tailor your content and marketing to the right people.
  • See What Content Works: Discover your most popular pages and blog posts. Knowing what resonates allows you to create more of what your audience loves and improve content that isn't performing well.
  • Track Your Marketing Channels: Find out how people are finding you. Is it through a Google search, Facebook, a link from another website, or an email newsletter? This tells you where to focus your marketing budget and effort.
  • Monitor Goals and Conversions: You can set up GA to track important actions, like form submissions, newsletter sign-ups, or product purchases. This connects your website activity directly to business results.
  • Identify Problems: See which pages have a high exit rate. This could signal a broken link, confusing navigation, or content that just isn't meeting user expectations, giving you a chance to fix it.

Step 1: Create Your Google Analytics Account and Property

Before you can add any code to your site, you first need a Google Analytics account. If you already have a Google account (like for Gmail or YouTube), you can use that to sign in.

1. Go to the Google Analytics Website

Navigate to the Google Analytics homepage and click "Start measuring." You'll be prompted to sign in with your Google account credentials.

2. Create an Account

The first step is setting up an "Account." This is the highest level of organization and usually represents your company or organization. Give it a name you'll recognize, like your business name.

Underneath, you'll see some "Account Data Sharing Settings." These control how your data is shared with Google for things like technical support and benchmarking. You can review and adjust these settings as you see fit. Click "Next" when you're ready.

3. Create a Property

Next, you'll create a "Property." A Property represents your website or app and contains all the reports for that specific digital asset. For example, if you have three different websites for your business, you could have three separate properties under one account.

  • Property Name: Enter a name for your website (e.g., "My Business Website").
  • Reporting time zone: Select the time zone you typically operate in. This ensures your daily reports align with your business day.
  • Currency: Choose your primary currency. This is especially important for ecommerce tracking.

Click "Next."

4. Provide Your Business Information

On the next screen, you’ll be asked to provide some optional details about your business, such as your industry category and business size. This information helps Google provide you with benchmarking data and tailor the experience. It doesn't impact your data collection, so feel free to choose the options that fit best.

You'll then choose your business objectives. Pick the outcomes that are most important to you - like "Generate leads," "Drive online sales," or "Raise brand awareness." Selecting these helps Google Analytics customize the default reports you see in your dashboard to be more relevant to your goals.

After you click "Create" and accept the terms of service, your account and property will be ready.

Step 2: Set Up a Data Stream and Get Your Tracking ID

Once your property is created, Google Analytics will prompt you to set up your first "Data Stream." This is simply the source of data flowing into your property. Since you're tracking a website, this is an easy step.

  1. Choose a platform: You'll see three options: "Web," "Android App," and "iOS App." Click "Web."
  2. Set up your web stream: Enter your website's URL (e.g., www.yourwebsite.com) and give your stream a name (e.g., "Main Website Stream"). Make sure "Enhanced measurement" is turned on - it automatically tracks common user interactions like page views, scrolls, and outbound clicks without any extra setup.
  3. Click "Create stream."

After clicking create, a "Web stream details" page will appear. This page contains the single most important piece of information you need: the Measurement ID. It will look something like G-XXXXXXXXXX. This ID uniquely identifies your data stream, and it's what you'll use to connect your website to Google Analytics.

Step 3: Add the Google Analytics Tracking Code to Your Website

Now that you have your Measurement ID, it's time to install the tracking code. How you do this depends entirely on how your website is built. We'll cover the most common methods below.

Method 1: Manually Adding the Google Tag to Your Website's Code

This method is for a custom-built website or for those who are comfortable editing their site's HTML files. It involves putting a snippet of JavaScript code - called the Google Tag (gtag.js) - on every page of your site.

In your Analytics Web stream details, under "Installation instructions," you'll see a code snippet. It looks 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>

Instructions:

  1. Copy the entire code block.
  2. Open the HTML code for your website. Most sites have a common header file (like header.php or head.html) that is included on every page. This is the ideal place to add the code.
  3. Paste the code snippet immediately before the closing </head> tag.
  4. Save and publish your changes. By placing it in a shared header, you ensure the tag loads on every page your visitors browse.

Method 2: Using a Plugin on Your WordPress Website

If your website runs on WordPress, the easiest and safest way to add Google Analytics is with a plugin. This avoids any risk of breaking your site by editing code directly.

Using Google Site Kit (Recommended): Site Kit is Google's official WordPress plugin, making it the most seamless option.

  • In your WordPress dashboard, navigate to Plugins > Add New.
  • Search for "Site Kit by Google," then click "Install Now" and "Activate."
  • A setup wizard will launch. Follow the prompts to connect Site Kit to your Google account. It will automatically detect your new Analytics property and link it to your site. A major benefit is that it also adds key metrics right into your WordPress dashboard.

Using Other Plugins: Many other plugins, like "GA Google Analytics" or "MonsterInsights," can also get the job done. With most of these alternative plugins, the process is simple: install the plugin, go to its settings page, and paste your Measurement ID (G-XXXXXXXXXX) into the designated field. Save your changes, and you're good to go.

Method 3: Using Built-in Integrations (Shopify, Squarespace, Wix)

Most modern website builders and ecommerce platforms have a built-in feature to add Google Analytics without touching code.

For Shopify:

  1. From your Shopify admin, go to Online Store > Preferences.
  2. Scroll down to the "Google Analytics" section.
  3. Paste your Measurement ID (G-XXXXXXXXXX) into the box.
  4. Click "Save." Shopify will handle the rest.

For Squarespace:

  1. In the Home menu, go to Settings > Website > External API Keys.
  2. Paste your Measurement ID into the box under "Google Analytics Measurement ID."
  3. Click "Save."

Wait, What About Google Tag Manager (GTM)?

You may have heard of Google Tag Manager. GTM is a more advanced tool that acts as a container for all of your marketing and analytics tags (like the Google Tag, Facebook Pixel, etc.). Instead of adding lots of different code snippets to your site, you just add one GTM snippet, then manage everything else from the GTM interface.

For a beginner, setting up Google Analytics directly as shown above is perfectly fine. But as your needs grow, migrating to GTM is a smart move that gives you much more power and flexibility. Consider it a great "next step" in your analytics journey.

Step 4: Verify That Google Analytics Is Working

You're almost done! The final step is to make sure data is actually being sent to your Google Analytics account.

  1. Log in to your Google Analytics account.
  2. On the left-hand menu, navigate to Reports > Realtime.
  3. In a separate browser window (it's best to use an incognito or private window to avoid being filtered out), visit your website.
  4. Go back to the Realtime report in analytics. Within a minute or two, you should see at least one active user appear. You'll see a "1" in the "Users in last 30 minutes" card, and you should see activity on a map and in a chart showing which page you're viewing.

If you see your visit pop up, congratulations! Your tracking is installed correctly. Keep in mind that it can take 24-48 hours for data to fully process and appear in the standard demographic and acquisition reports, so don't be alarmed if they're empty for the first day.

Final Thoughts

Congratulations - you've successfully installed Google Analytics! By adding that small piece of code, you've opened a window into your website's performance, allowing you to understand your visitors and grow your business with confidence. Let the data roll in, and start turning those numbers into actionable insights.

Once you gather more data, the real work of analysis begins. Instead of struggling to find answers in rows of data, we created Graphed to do the heavy lifting for you. We connect to your Google Analytics account and let you build dashboards and get insights just by asking questions in plain English - like "create a dashboard comparing organic traffic vs paid traffic growth this quarter." It's the fastest way to turn your raw website data into clear answers.

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.