Adding Google Analytics to Your Website
Last Updated: 2025-01-01
2 min read
Adding Google Analytics to Your Website
Google Analytics is a free tool that tracks visitor behavior, traffic sources, and conversions on your website. Google Analytics 4 (GA4) is the current version and uses an event-based data model for more flexible reporting.
Step 1: Create a Google Analytics Account
- Go to analytics.google.com.
- Click Start measuring and create an account.
- Enter an Account Name (e.g., your business name).
- Create a Property — enter your website name, reporting time zone, and currency.
- Set up a Web Data Stream: Enter your website URL and stream name.
- Google will generate a Measurement ID (starts with
G-). Copy this — you’ll need it.
Step 2: Add the Tracking Code
Method A: Direct HTML Insertion
Paste the Global Site Tag (gtag.js) in the <head> section of every page:
<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 Measurement ID.
Method B: WordPress Plugin
- Install a plugin like Site Kit by Google, MonsterInsights, or GA Google Analytics.
- Connect your Google account and select your property.
- The plugin automatically inserts the tracking code on all pages.
Method C: Google Tag Manager
- Create a Google Tag Manager account and container.
- Add the GTM snippet to your site’s
<head>and<body>. - In GTM, create a new tag with your GA4 Measurement ID.
- Set the trigger to “All Pages” and publish.
Step 3: Verify Tracking
- Visit your website in a browser.
- In Google Analytics, go to Reports → Realtime.
- You should see your visit appearing within a few seconds.
Key Reports to Monitor
- Acquisition: See where your traffic comes from (search, social, direct, referral).
- Engagement: Track page views, session duration, and bounce rate.
- Conversions: Set up goals to measure form submissions, purchases, or sign-ups.
- Demographics: Understand your audience’s location, language, and devices.
Privacy Considerations
- Update your privacy policy to disclose analytics tracking.
- Implement a cookie consent banner if required by GDPR, CCPA, or other regulations.
- Enable IP anonymization if required in your jurisdiction.
- Consider using Google’s consent mode for compliance.
Analytics data typically takes 24–48 hours to fully populate in reports.
Tags:
website
analytics
google-analytics
tracking
ga4