How to Tag Your Website for Google Analytics

Cody Schneider8 min read

Getting Google Analytics set up on your website is the crucial first step to understanding how people find and interact with your content. The process boils down to adding a special piece of code - a "tag" - to your site that communicates with Google. This article walks you through exactly how to tag your website, whether you’re using a platform like WordPress or Shopify, a tool like Google Tag Manager, or need to do it by hand.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

What is a Google Analytics Tag, Anyway?

A Google Analytics tag is a small snippet of JavaScript code. When you place this code on your website, it runs in your visitors' browsers, collecting anonymous data about their activity - like which pages they visit, how long they stay, and where they came from. It sends this information back to your Google Analytics account, where it’s processed into the reports you use to measure performance.

Without this tag, your Google Analytics account is an empty box. It has no way of seeing what’s happening on your website. Installing the tag is like turning on the lights and opening the door for data to flow in.

For modern analytics, we're focusing on Google Analytics 4. Its tagging system is handled by the "global site tag" (gtag.js), which is designed to be more flexible and future-proof than the older tags used for Universal Analytics.

Before You Begin: Get Your GA4 Measurement ID

Before you can tag your site, you need the unique identifier for your Google Analytics property. Think of this ID as the mailing address for your data, it tells the tag where to send all the information it collects. If you already have a GA4 account and property set up, you can skip to grabbing your ID. If not, here's a quick rundown.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

1. Create a Google Analytics Account and Property

First, head over to the Google Analytics website and sign in with your Google account. You’ll be prompted to create an account (this is usually your company or organization's name).

Next, you’ll create a "Property." A property represents your website or app. Give it a name (e.g., "My Business Website"), select your reporting time zone and currency, and proceed.

2. Set Up a Data Stream

A "Data Stream" is a source of data flowing into your GA4 property. Since you’re tracking a website, you’ll choose the "Web" option.

  • Enter your website’s URL (e.g., www.mycoolsite.com).
  • Give the stream a name (e.g., "Main Website Stream").
  • Make sure "Enhanced measurement" is turned on. This feature automatically tracks common interactions like page views, scrolls, outbound link clicks, and file downloads without any extra setup.
  • Click "Create stream."

3. Find and Copy Your Measurement ID

After creating your stream, a "Web stream details" page will appear. In the top right corner, you'll see your "Measurement ID". It will be in the format G-XXXXXXXXXX.

This "G-" ID is the key piece of information you'll need for most installation methods. Copy it and keep it handy.

How to Tag Your Website: Three Main Methods

There are a few ways to get the GA tag onto your website. We’ll go from the easiest to the most technical, starting with the method that works for most people.

Method 1: Use a Platform Integration or Plugin (The Easiest Way)

Most modern website builders and content management systems (CMS) know how important analytics are, so they have built-in features or recommended plugins to make installation a simple copy-and-paste job. This is the best route for non-technical users.

For WordPress Websites:

The easiest way to add Google Analytics to a WordPress site is with a plugin. Plugins like MonsterInsights, Site Kit by Google, or GA Google Analytics handle all the code placement for you.

  1. Install and activate your chosen analytics plugin from your WordPress dashboard.
  2. Follow the plugin's setup wizard. It will ask you to connect your Google account and select the correct GA4 property.
  3. The plugin automatically inserts the tracking code snippet in the right place. In many cases, you don't even need to touch your Measurement ID.

Some WordPress themes also have a dedicated spot in their theme options (usually under "Header/Footer Scripts" or "Integrations") where you can paste the full JavaScript snippet or just your Measurement ID.

For Shopify Stores:

Shopify makes this incredibly straightforward.

  1. From your Shopify Admin, go to Online Store > Preferences.
  2. Find the "Google Analytics" section.
  3. Paste your GA4 Measurement ID ("G-XXXXXXXXXX") into the field provided.
  4. Click "Save."

Shopify will automatically add the gtag.js script to your store, along with special features for tracking e-commerce events like adding to cart and making a purchase.

For Other Platforms (Wix, Squarespace, etc.):

Look for a section called "Integrations," "Marketing Tools," or "Custom Code." Most have a dedicated field for your Google Analytics ID. Simply paste your "G-" ID, save your changes, and you're good to go.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

Method 2: Use Google Tag Manager (The Most Powerful Way)

Google Tag Manager (GTM) is a free tool that acts as a middleman between your website and all your marketing tags (like Google Analytics, Facebook Pixel, etc.). It’s the recommended approach for anyone who anticipates wanting to track more than just basic page views in the future.

The setup is a little more involved, but its long-term benefits are huge.

  1. Create a GTM Account: Go to the Google Tag Manager website, create an account, and set up a new "container" for your website.
  2. Install GTM on Your Site: GTM itself requires a one-time code installation. It will give you two snippets to paste - one in the <head> of your website and one after the opening <body> tag. Many site builders and plugins have dedicated fields for your GTM ID (GTM-XXXXXX), which does this for you.
  3. Create the GA4 Tag Inside GTM:
  4. Set the Trigger: Next, click "Triggering" and select All Pages. This tells GTM to fire the GA4 tag on every single page of your site as it loads.
  5. Preview and Publish: Use GTM’s powerful Preview mode to test that your tag is firing correctly on your live site. Once confirmed, click "Submit" and "Publish" to push your changes live.

Method 3: Manually Add the Tag to Your Code (The Direct Approach)

If you have a custom-built website or prefer not to use plugins or GTM, you can place the Google Analytics tag directly into your site’s HTML.

1. Get the Full Code Snippet

In Google Analytics, navigate to your data stream details (Admin > Data Streams > Your Web Stream), and under "View tag instructions," find the Global Site Tag (gtag.js) and copy the entire JavaScript code block.

It will look something like this:

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

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

2. Paste the Snippet into Your Site's <head>

This code needs to be placed on every single page you want to track. The best practice is to paste it in a master header file or template immediately after the opening <head> tag. This ensures it loads early, maximizing its ability to capture data before a user navigates away.

Warning: Be very careful when editing your site’s code directly. A small typo can break your layout or functionality.

GraphedGraphed

Still Building Reports Manually?

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

Watch Graphed demo video

How to Verify Your Tag is Working

Once you’ve installed the tag, don't just assume it’s working. Here’s how to check:

  • Realtime Report: The easiest way is to open your website in one browser tab and your Google Analytics "Realtime" report in another. You should see yourself show up as an active user "in past 30 minutes". Interacting with your site should trigger activity in the report.
  • Google Tag Assistant: Use the official Tag Assistant Companion browser extension. It scans the tags on your page and tells you if your GA4 tag was found and if it's firing correctly.
  • GA4 DebugView: For more advanced testing, especially when using Google Tag Manager, the "DebugView" section in the GA4 Admin panel is invaluable. It provides a real-time stream of all events coming from your browser while in Preview mode.

Next Steps: Tracking Custom Actions

The base tag successfully tracks page views and other standard user engagements thanks to enhanced measurement. The real power comes when you start tagging specific user actions crucial to your business, like form submissions for lead generation, clicks on a "Request a Demo" button, or watching a product video.

This is where using Google Tag Manager truly shines. GTM allows you to set up “Event Tags” that fire when users take these specific actions, all without ever asking a developer to add more code to the site. Once the main tag is installed, you can expand your tracking capabilities dramatically right from the GTM interface.

Final Thoughts

Tagging your website for Google Analytics is the gateway to data-driven decision-making. Whether you use a simple plugin, the robust Google Tag Manager, or paste the code in yourself, taking this one step unlocks a world of insight into your audience and how they engage with your business online.

Once your data starts flowing into analytics, the next challenge is turning piles of reports into clear, actionable insights. That's where we've worked hard to make things easier. After connecting your Google Analytics account, you can use Graphed to ask questions in plain English - like "create a dashboard showing my top traffic sources and conversion rates for last month" - and get a real-time dashboard built in seconds. This saves you the headache of manually building reports in GA, letting you focus on strategy instead of struggling with the interface.

Related Articles