How to Link Google Analytics to Website

Cody Schneider

Connecting your website to Google Analytics is the first step toward understanding how your visitors find and interact with your content. It unlocks a wealth of data that can help you make smarter decisions about marketing, content, and user experience. This guide will walk you through setting up a new Google Analytics 4 account and show you the most common ways to link it to your website.

First Things First: Create or Log In to Your Google Account

Before you can do anything else, you need a Google account. The good news is that if you use Gmail, Google Drive, or any other Google service, you already have one. You can use your existing account to set up Google Analytics.

If you don't have a Google account, head over to the Google Account creation page and set one up. It’s free and only takes a couple of minutes.

Creating Your Google Analytics 4 Account and Property

With your Google account ready, it’s time to create your Analytics account. Google Analytics is structured with a simple hierarchy: Accounts > Properties > Data Streams.

  • Account: This is the highest level, typically named after your business or organization. You can have multiple websites (properties) under one account.

  • Property: This represents a specific website or app you want to track. If you run three different websites, you might have three properties under one account.

  • Data Stream: This is the source of data for your property. For a website, it will be a "Web" data stream.

Follow these steps to get everything set up.

Step 1: Start the Setup Process

Go to the Google Analytics website and click "Start measuring." You'll be logged in with your Google account and taken to the account creation screen.

Step 2: Create Your Account

The first screen asks you to set up your account.

  • Account name: Enter your business name here. For example, "My Awesome Company."

  • Account Data Sharing Settings: These settings give you control over how your data is shared with Google. For most users, leaving them checked is fine.

Click "Next" when you're done.

Step 3: Create Your Property

Next, you’ll create your first property (your website).

  • Property name: Enter the name of your website. For example, "My Awesome Website." This helps you easily identify it if you add more properties later.

  • Reporting time zone: Select the time zone you operate in. This ensures your daily reports align correctly with your business day.

  • Currency: Choose your primary currency. This is especially important for ecommerce sites.

Click "Next" to continue.

Step 4: Provide Business Details

On the next screen, Google asks for some general information about your business. This helps them with benchmarking and customizing your experience. Select your industry, business size, and how you intend to use Analytics. Answering these questions helps GA4 suggest relevant reports.

Click "Create" and then accept the Google Analytics Terms of Service Agreement.

Step 5: Set Up Your Web Data Stream

After accepting the terms, you’ll be prompted to set up your first data stream. Since you're connecting a website, choose the "Web" platform.

You’ll need to provide two pieces of information:

  • Website URL: Enter your website’s address (e.g., www.myawesomewebsite.com).

  • Stream name: This will pre-fill with your URL, which is perfectly fine.

Make sure "Enhanced measurement" is turned on. This is a powerful feature in GA4 that automatically tracks key events like page views, scrolls, outbound clicks, site search, and video engagement without any extra setup. Now, click "Create stream."

Step 6: Find Your Measurement ID and Tracking Code

Once you create the stream, you'll land on the "Web stream details" page. This page contains the critical information you need to link Analytics to your website. You'll see two key items:

  • Measurement ID: A unique identifier that starts with "G-" (e.g., G-XYZ123ABC). Some platforms and plugins will only ask for this ID.

  • Global site tag (gtag.js): A snippet of JavaScript code. This is what you’ll add to your website's HTML to start collecting data.

Keep this tab open. In the next section, we’ll use this code or ID to make the connection.

How to Add the Google Analytics Code to Your Website

Now that your GA4 property is ready, it's time to add its tracking code to your website. There are several ways to do this, ranging from manual implementation to easy-to-use plugins. Choose the method that best fits your technical comfort level and website platform.

Method 1: Manually Paste the Code into Your Website’s HTML

This method involves editing your website’s code directly. It's best if you're comfortable working with HTML or are using a simple site without a CMS (Content Management System).

The goal is to place the Global Site Tag (gtag.js) script into the <head> section of every page on your website.

  1. From your "Web stream details" page in Google Analytics, find the "Global site tag (gtag.js)" section and click "Copy." The code will look something like this:

  1. Open your website's HTML files. If your site has a theme, you might find a template file like header.php or head.html that controls the header for every page. Editing this single file can apply the code site-wide.

  2. Paste the copied code just before the closing </head> tag.

  3. Save and publish your change. The code will now be active on your site.

Method 2: Use a Plugin (The Easiest Way for WordPress)

If you have a WordPress website, using a plugin is by far the simplest and safest option. It removes the risk of breaking your site's code and often adds powerful reporting features directly into your WordPress dashboard.

We recommend using Google’s official plugin, Site Kit by Google.

  1. Log in to your WordPress dashboard.

  2. Navigate to Plugins > Add New.

  3. In the search bar, type "Site Kit by Google."

  4. Click "Install Now" and then "Activate" on the plugin.

  5. A banner will appear prompting you to start the setup. Click "Start Setup."

  6. Follow the on-screen prompts to sign in with the same Google account you used to create your Analytics property.

  7. Site Kit will automatically detect your new Analytics account and property. Simply grant it permission to connect.

That’s it! Site Kit handles adding the tracking code and even pulls in your analytics data so you can see basic reports without leaving WordPress.

Method 3: Use a Built-in Integration (for Squarespace, Wix, Shopify)

Most modern website builders and ecommerce platforms have a dedicated field for Google Analytics, making installation incredibly easy. For this method, you only need your Measurement ID (the G-XXXXXXX string).

For Squarespace:

  1. Log in to your Squarespace dashboard.

  2. Go to Settings > External API Keys.

  3. In the "Google Analytics Measurement ID" field, paste your "G-" Measurement ID.

  4. Save your changes.

For Wix:

  1. Log in to your Wix dashboard.

  2. Go to Marketing & SEO > Marketing Integrations.

  3. Under "Google Analytics," click "Connect."

  4. Click "Connect Google Analytics" and then paste your "G-" Measurement ID into the popup window.

  5. Click "Save." That’s all you need to do!

For Shopify:

  1. Log in to your Shopify admin panel.

  2. Go to Online Store > Preferences.

  3. Find the "Google Analytics" section and click "Manage pixel here."

  4. Follow the prompts to add the official Google channel to your Shopify store, then connect your Google account.

  5. It will automatically detect and link your GA4 property for you, no ID needed.

Method 4: Using Google Tag Manager (The Advanced Method)

Google Tag Manager (GTM) is a free tool that acts as a container for all your marketing and analytics scripts (or "tags"). It's the recommended approach for marketers and anyone who plans to manage multiple scripts like the Facebook Pixel, Google Ads conversion tags, etc., without repeatedly editing website code.

  1. Install Google Tag Manager on your site first. If you haven't already, sign up at tagmanager.google.com and install its container code on your site (similar to the manual method).

  2. In your GTM Workspace, go to Tags > New.

  3. Name your tag something clear, like "GA4 Configuration."

  4. Click on "Tag Configuration" and choose Google Analytics: GA4 Configuration from the list.

  5. Paste your Measurement ID ("G-XXXXXXX") into the corresponding field.

  6. Next, click on "Triggering" and select the Initialization - All Pages trigger. This tells GTM to fire the GA4 tag on every page of your site.

  7. Click "Save," and then click the "Submit" button in the top right corner to publish your changes.

Confirming That Your Setup Is Working

Once you’ve installed the tracking code, you’ll want to confirm that Google Analytics is receiving data. The great thing is that you can check immediately using the Realtime report.

  1. Go to your Google Analytics property.

  2. On the left-hand navigation menu, go to Reports > Realtime.

  3. Open your website in a new browser tab or on your phone.

  4. Within a minute, you should see yourself as an active user on the Realtime report. The map will show your location, and the cards will update with information about your session.

If you see your activity, congratulations! You have successfully linked Google Analytics to your website. Keep in mind that standard reports may take 24-48 hours to fully populate with detailed data.

Final Thoughts

Connecting your website to Google Analytics is a straightforward process when you know the steps. Whether you add the code manually, use a dedicated plugin or website builder feature, or leverage the power of Google Tag Manager, you’re now capturing vital data that will help you understand your audience and improve your online presence.

Once data starts flowing, the real work begins: turning numbers into actionable insights. We built Graphed to make this next step effortless. Instead of spending hours digging through GA4 reports, you can connect your Analytics account to our platform and simply ask questions in plain English - like "Which blog posts brought in the most new users this month?" We instantly build the reports and dashboards you need, giving you back time to focus on growing your business.