G
GrowWebPro
Website Basics

How to Connect Google Analytics to Your Website

Google Analytics shows you who visits your website, where they came from, and what they do. Here's how to set it up in under 10 minutes.

2 min read · Updated 2026-04-15

How to Connect Google Analytics to Your Website

Short answer

Create a free Google Analytics 4 account, add your website as a property, copy the tracking code (G- tag), and paste it into your website's <head>. Google Analytics starts collecting data within 24 hours.

Step-by-step setup

Step 1: Create a Google Analytics account

Go to analytics.google.com and sign in with your Google account. Click Start measuring and follow the prompts to create an account and property.

Step 2: Set up a data stream

Choose Web as your platform, enter your website URL and name, and click Create stream. You'll get a Measurement ID (starts with G-).

Step 3: Add the tracking code to your website

If you use a website builder:

  • Squarespace: Settings → Developer Tools → Code Injection → paste in <head>
  • Wix: Dashboard → Marketing & SEO → Google Analytics → enter your G- ID
  • Shopify: Online Store → Themes → Edit code → paste in theme.liquid before </head>
  • WordPress: Use the Site Kit by Google plugin — it connects GA4, Search Console, and AdSense in one click

If you have custom HTML:

<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>

Replace G-XXXXXXXXXX with your actual Measurement ID.

What Google Analytics shows you

  • Users — how many people visited your site
  • Sessions — how many visits (one user can have multiple)
  • Traffic sources — Google search, social media, direct, referrals
  • Top pages — which pages get the most views
  • Location — where your visitors are from
  • Device — mobile vs desktop vs tablet

Verifying it works

In GA4, go to Reports → Realtime and open your website in another tab. You should see yourself appear as an active user within 30 seconds.

Related questions