How to Set Up a Website with Google Analytics

Cody Schneider9 min read

Setting up Google Analytics is the first step toward understanding what’s actually happening on your website. It’s the free, powerful tool that shows you who your visitors are, how they found you, and what they do once they arrive. This guide provides a clear, step-by-step walkthrough for creating your Google Analytics 4 account and installing the tracking code on your site, no matter what platform you use.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

First Things First: Why Bother with Google Analytics?

In short, Google Analytics (GA) turns visitor actions into insights. Instead of guessing, you get hard data to answer critical questions that can help you grow your business, including:

  • Who are my visitors? Understand their geographic location, the devices they use (mobile vs. desktop), and other key demographic information.
  • How did they find my website? See your traffic sources broken down by channel - like search engines (Google, Bing), social media (Facebook, Instagram), referral links from other websites, or direct type-in traffic.
  • What pages are most popular? Identify which content resonates with your audience and which pages might need improvement.
  • Is my marketing effective? Track the performance of specific campaigns to see which emails, ads, or social media posts are driving the most traffic and conversions.

If you've heard of "Universal Analytics" (UA), it's important to know that Google officially replaced it with Google Analytics 4. All new setups use GA4, and this guide will focus exclusively on getting you started with this current, more powerful version.

Step 1: Create Your Google Analytics 4 Account and Property

Before you can track anything, you need a place for the data to live. This involves creating an account and a "property" inside it. Think of the account as the main folder for your business, and a property as the sub-folder for a specific website or app.

Here’s how to set it up:

  1. Navigate to the Google Analytics website and sign in with your existing Google account (the one you use for Gmail, Google Drive, etc.). If you don't have one, you'll need to create one first.
  2. Once signed in, click "Start measuring."
  3. Create your account. You'll be prompted to enter an "Account name." This is for your internal use, your business name is a good choice here. Below, you'll see "Account Data Sharing Settings." These control what data you share with Google. For most people, leaving these defaults checked is fine. Click "Next."
  4. Create your property. Now you’ll set up the property.
  5. Click "Next."
  6. Provide business details. On the next screen, help Google understand your business by selecting your industry, business size, and how you intend to use Analytics (e.g., "Generate leads," "Drive online sales"). This helps GA4 customize the reports it shows you by default. After making your selections, click "Create."
  7. Finally, you'll have to accept the Google Analytics Terms of Service. Check the box and click "I Accept."

That’s it! Your account and property are now created. Next, Google will immediately prompt you to set up your "data stream."

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

Step 2: Find Your Google Tag (Measurement ID)

A "data stream" is simply the source of data flowing into your GA4 property. Is the data coming from a website, an iOS app, or an Android app? Since you're setting up analytics for a website, you’ll choose "Web."

  1. On the "Data collection" screen, click "Web."
  2. Enter your website’s URL (e.g., mycoolwebsite.com) and give the stream a name (e.g., "Main Website").
  3. Leave "Enhanced measurement" turned on. This is a powerful GA4 feature that automatically tracks common interactions like page views, scrolls, outbound clicks, and file downloads without any extra setup.
  4. Click "Create stream."

Once you create the stream, a page called "Web stream details" will appear. This screen is important. It contains the tracking code you need to add to your website. You'll see two key things:

  • MEASUREMENT ID: A unique identifier that starts with "G-" followed by a string of letters and numbers. Sometimes, platform integrations will only ask for this ID.
  • Global site tag (gtag.js): A small block of JavaScript code. You will need to copy this entire snippet if you're installing GA manually.

Keep this tab open. The next step is adding this code to your website.

Step 3: Add the Tracking Code to Your Website

Getting your GA tag onto your website is the most crucial step. How you do it depends on the platform your website is built on. We’ll cover the most common methods, from easiest to most advanced.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

Option A: The Easy Way (Using a Plugin or Integration)

For most people using a content management system (CMS) like WordPress or a website builder like Shopify or Squarespace, this is the best method. It doesn't require touching any code.

For WordPress Websites

Plugins make installation on WordPress a breeze. Popular choices like "Site Kit by Google" or "MonsterInsights" can automatically install your GA4 tag by having you just log in to your Google Account. For an even simpler approach, plugins like "GA Google Analytics" just require you to paste your Measurement ID. General steps for a plugin install:

  1. From your WordPress dashboard, navigate to "Plugins" → "Add New."
  2. Search for a Google Analytics plugin.
  3. Click "Install Now" and then "Activate".
  4. Find the plugin’s settings and follow its instructions. It will likely ask you to either connect your Google account or simply paste your "G-" Measurement ID into a settings field.
  5. Save your changes.

For Shopify Stores

Shopify makes this simple through their native "Google & YouTube" app.

  1. From your Shopify admin, go to "Apps" and search for the "Google & YouTube" app. Install it.
  2. Follow the setup process, which will prompt you to connect your Google account.
  3. During setup, it will ask for your Google Tag. Copy the "G-" Measurement ID from your GA4 data stream page and paste it into the field.
  4. Complete the setup process. Shopify will add the tag to all of your store’s pages for you.

For Squarespace, Wix, or Other Builders

Most website builders have a dedicated field for Google Analytics integration.

  1. Look in your site’s settings for a section called "Integrations," "Analytics," or "Marketing".
  2. You should find a field specifically labeled "Google Analytics" or asking for a "Measurement ID".
  3. Copy your "G-" Measurement ID and paste it into this field.
  4. Save your settings. The platform will handle the rest.

Option B: The Manual Way (Adding Code to Your Website's Header)

If you have a custom-coded website or you're comfortable editing theme files, you can add the tracking code manually. Before you do this, always back up your website files or theme.

  1. Go back to the GA4 "Web stream details" page and find the "Global site tag (gtag.js)" section. Copy the entire code snippet that starts with <!-- Global site tag (gtag.js) - Google Analytics -->.
  2. Access your website’s source code. You need to find the main template file that contains the opening <head> HTML tag. On many platforms, this file is named header.php or head.html.
  3. Paste the entire code snippet you copied right after the opening <head> tag.
  4. Save the file and upload it to your server if needed. The tag is now on every page that uses this header file.

Option C: Using Google Tag Manager (The Advanced & Best Way)

Google Tag Manager (GTM) is a separate free tool from Google that acts as a central hub for all your tracking tags (Analytics, Facebook Pixel, Google Ads, etc.). While it has a steeper learning curve, it's the most flexible and powerful way to manage tracking. The basic idea is you install the GTM code on your site once, and then you use the GTM interface to add, remove, and manage tags like Google Analytics without ever having to edit your website's code again.

  1. Create a Google Tag Manager account and container for your website.
  2. Install the GTM container code on your site (similar to the manual method above).
  3. Inside your GTM account, create a new "Tag." Choose "Google Analytics: GA4 Configuration."
  4. Paste your "G-" Measurement ID in the configuration field.
  5. Set the "Trigger" for this tag to fire on "All Pages."
  6. Save, "Preview" your changes to test them, and then hit "Submit" to publish the changes live.
GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

Step 4: Verify That Google Analytics is Working

Once you've installed the tag, how do you know it’s collecting data? You shouldn’t have to wait 24 hours just to see if you did it right. Luckily, there are ways to check immediately. The easiest method is using the Realtime report in Google Analytics:

  1. In your GA4 property, navigate to the sidebar on the left and click "Reports" > "Realtime."
  2. Open your website in a new browser tab (use an incognito window to make sure you appear as a new user).
  3. Within a minute or two, you should see yourself appear as a visitor in the Realtime report. The "Users" card should tick up to 1, and you'll see a map with your location.

If you see your visit, congratulations! You've successfully installed Google Analytics.

What Now? Setting Yourself Up for Success

Installation is just the beginning. The real value comes from configuring GA4 to track what matters to your business. Here are a few simple next steps:

  • Exclude Internal Traffic: You don't want your own visits and your team's visits skewing your data. Go to Admin > Data Streams > Configure tag settings > Define internal traffic. Here you can add your office's IP address so GA4 knows to filter it out.
  • Set Up Conversions: What is the most important action a visitor can take on your site? Submitting a contact form? Making a purchase? Signing up for a newsletter? You can define these actions as "conversions" in GA4 to easily measure how often they occur.
  • Get Familiar with Reports: Spend some time clicking through the standard reports - especially "Engagement" (to see which pages are popular) and "Acquisition" (to see where your traffic comes from).

Final Thoughts

Getting Google Analytics up and running on your website is one of the most valuable things you can do for your business. You now have the foundational setup needed to track your website's performance, learn about your audience, and make smart, data-driven decisions instead of relying on guesswork. Setting this up is a fantastic first step, but the next challenge is turning all that data into straightforward insights. At Graphed, we found that many marketers and business owners spend too much time navigating confusing reports to find simple answers. That's why we built Graphed. We simplify your analytics by allowing you to connect data sources like Google Analytics and then just ask for what you need in plain English. Instead of digging through menus, you can just ask, "Show me my top landing pages from organic search last month," and get an instant visualization.

Related Articles