How to add Google Analytics 4 to your website
Set up Google Analytics 4 in about five minutes: create an account and property, add a web stream, and put the Google tag on every page of your site.
To add Google Analytics 4, create a GA4 account and property at analytics.google.com, add a web data stream for your site, then paste the Google tag (a short script with your Measurement ID, G-…) into the <head> of every page. It takes about five minutes, and visits start showing within a minute in GA4's Realtime report.
What you need
- A Google account (the one you want to own the analytics).
- Access to your site's code, or to its builder's settings (Webflow, WordPress, Framer and so on).
If your site runs on a builder, the platform guides below are quicker: most have a field where you paste the Measurement ID.
1. Create a Google Analytics account and property
Go to analytics.google.com and choose Start measuring.
Account: give it a name, usually your company or your own name. One account can hold many sites.
Property: name it after your site (for example "mysite.com"), and set the time zone and currency you work in. The time zone decides when your days start and end, in GA4 and in SimpleDash.
Answer the questions about your business and goals. They only change which reports GA4 suggests.
2. Add a web data stream
When GA4 asks where to collect data, choose Web.
Enter your site's address (for example mysite.com) and a stream name.
Leave Enhanced measurement on. It counts page views, scrolls, outbound clicks, file downloads, form interactions and site searches without extra code.
Choose Create stream (or Create & continue). GA4 shows your Measurement ID, which starts with G-.
You can find the Measurement ID again any time in Admin → Data collection and modification → Data streams → your stream.
3. Add the Google tag to every page
GA4 shows installation instructions. Choose Install manually and copy the code, which looks like this (with your own ID instead of G-XXXXXXXXXX):
<!-- 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>Paste it right after the opening <head> tag on every page of your site. On most sites that means one shared layout or header file.
On a website builder or framework
Next.js
WordPress
Webflow
Framer
Shopify
Ghost
Lovable and AI app builders
Squarespace
Wix
Carrd
Astro
Plain HTML
Google Tag Manager
Using an AI coding agent like Claude Code or Cursor? Give it this ready prompt.
4. Check it works
Open your site in another tab, then open GA4's Reports → Realtime overview. You should appear within a minute. If you don't, see Check that GA4 is collecting data.
Do you need a cookie banner?
If your visitors are in the EU, the UK or another place with similar rules, you usually need consent before GA4 sets its cookies. Cookie banners and Consent Mode for GA4 explains the options. This isn't legal advice.
Next steps
- Stop counting your own visits.
- Count signups and mark them as key events.
- If you take payments, stop Stripe or PayPal taking credit for your sales.
Sources
- Google: Set up Analytics for a website and/or app
- Google: Enhanced measurement events
Last updated
Setup checklist
The complete GA4 setup for a small site, in order: create the property, add the tag, check it, exclude yourself, track signups and sales, and fix referrals.
Check GA4 works
Three quick ways to check that GA4 is working on your site, Realtime, DebugView and your browser's network tab, plus the five most common reasons it isn't.