#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Set Up Google Analytics 4 for a Blog or Portfolio

Google Analytics 4 (GA4) tells you how many people visit your blog or portfolio, where they come from, which pages they read and what they click. Setup takes about 20 minutes: create a property, add one tag, confirm data arrives, then mark the actions you care about as key events.

Set Up Google Analytics 4 for a Blog or Portfolio

Google Analytics 4 is the current version of Google Analytics. The older Universal Analytics stopped processing data on 1 July 2023, so any guide that mentions "UA-" tracking IDs or "bounce rate views" is out of date. GA4 records everything as events (a page view, a scroll, a click), and its reports are built from those events.

Step 1: Create a GA4 property and a web data stream

  1. Go to analytics.google.com and sign in with the Google account you want to own the data.
  2. Open Admin and choose Create > Account (or use an existing account), then Create > Property. Give it your site name, time zone and currency.
  3. When asked for a platform, choose Web. Enter your site URL (for example https://yourname.github.io) and a stream name.
  4. Leave Enhanced measurement switched on. It automatically tracks page views, scrolls, outbound clicks, site search, video engagement, file downloads and form interactions.
  5. Copy the Measurement ID. It looks like G-XXXXXXXXXX.

Step 2: Add the tag to your site

How you add the tag depends on how your site is built.

Hand-coded site or static site generator

Paste Google's tag into the <head> of every page, replacing the ID with yours:

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

On a static generator (Hugo, Jekyll, Astro, Next.js) or a React portfolio site, put it in the shared layout or head template so it appears on every page once.

WordPress

Use Google's official Site Kit plugin, or a header-scripts plugin to paste the tag. Do not add it twice (plugin and theme), or every page view will be counted twice.

Website builders

Wix, Squarespace, Blogger and similar builders have a field for a Google Analytics Measurement ID in their settings. Paste the G- ID there instead of the full script.

Google Tag Manager

If you already use Tag Manager, create a Google tag with your Measurement ID, trigger it on all pages, and publish the container.

Step 3: Check that data is arriving

  • Open your site in another tab, then go to Reports > Realtime in GA4. You should see at least one active user within a minute or two.
  • For more detail, install the Tag Assistant extension or open Admin > DebugView to watch events arrive one by one.
  • If nothing appears, check for an ad blocker, a typo in the ID, a cookie banner that blocks the tag until consent, or a cached page that does not include the new code yet.

Standard reports can take up to a day or two to fill in; Realtime is the quick check.

Step 4: Settings worth changing on day one

  • Data retention: Admin > Data collection and modification > Data retention. The default for detailed event data is 2 months; change it to 14 months so explorations can look back further. Standard reports are not affected by this setting.
  • Exclude your own visits: Admin > Data streams > your stream > Configure tag settings > Define internal traffic, add your IP address, then activate the internal traffic filter.
  • Link Search Console: Admin > Product links > Search Console links. This brings Google search queries and landing pages into GA4.

Step 5: Track the actions that matter

For a portfolio, the important actions might be "clicked my email", "downloaded my CV" or "opened my GitHub". For a blog, it might be newsletter sign-ups. In GA4 these are called key events (Google renamed "conversions" to key events in 2024).

File downloads and outbound clicks are already tracked by enhanced measurement. For a specific button, send your own event:

<a href="mailto:you@example.com"
   onclick="gtag('event', 'contact_click', { method: 'email' });">
  Email me
</a>

After the event has been received at least once, go to Admin > Events and mark contact_click as a key event. You can also create key events from existing ones, for example a page_view of your thank-you page.

Step 6: Read the reports that answer real questions

QuestionWhere to look in GA4
How many people visit?Reports > Home, or Reports > Engagement > Overview
Where do visitors come from?Reports > Acquisition > Traffic acquisition (by session default channel group)
Which posts are read most?Reports > Engagement > Pages and screens
Do people actually read?Average engagement time and engagement rate in the same report
Which pages bring visitors in first?Reports > Engagement > Landing page
Which searches bring people?Search Console reports after linking
Who contacts me or downloads my CV?Reports > Engagement > Events, filtered to your key events

GA4 counts a session as engaged if it lasts longer than 10 seconds, has a key event, or has two or more page views. Engagement rate is the share of engaged sessions, and bounce rate in GA4 is simply its opposite.

Turning numbers into decisions

  • A post with many visits but very short engagement time may not match what searchers wanted. Rewrite the opening to answer the question faster.
  • If most visitors arrive from organic search, invest in SEO: see SEO basics and this on-page SEO checklist for bloggers.
  • If portfolio visitors view projects but never click contact, make the contact link visible on every project page.
  • Compare month to month, not day to day; small sites have noisy daily numbers.

Privacy and consent

If your visitors include people in the EU or UK, you need a consent banner before setting analytics cookies, and Google's Consent Mode lets the tag respect that choice. India's Digital Personal Data Protection Act, 2023 also requires a clear notice for personal data. Add a short privacy page saying you use Google Analytics and what it collects. If you would rather avoid cookies entirely, see these Google Analytics alternatives.

FAQs

Is Google Analytics 4 free?

Yes, the standard version is free. Google Analytics 360 is the paid enterprise version with higher limits.

Why does GA4 show fewer visitors than my hosting stats?

GA4 only counts visitors whose browsers run the tag. Ad blockers, declined consent and bots filtered out by GA4 all reduce the count, while server logs count every request.

Can I use Google Analytics on a GitHub Pages portfolio?

Yes. Add the tag to the head of your HTML or to your site generator's layout template, then publish.

Analytics is one module in Uncodemy's digital marketing course, alongside SEO and paid ads, with Dedicated Placement Support.

Placed Students

Our Clients

Partners

...