Ultra Web Hosting Docs

Setting Up Google Analytics (GA4)

Google Analytics 4 is a free, client-side analytics platform that counts real visitors in the browser. Because it runs in the visitor's browser rather than reading server logs, it gives you accurate numbers even when a CDN or cache serves most of your pages. This guide walks you through creating a property and installing the tracking code.

Why GA4 Is More Accurate

Server-side tools like AWStats and Webalizer only see requests that reach your origin server. When a CDN such as Cloudflare caches your pages, many visits are served from the CDN and never touch the origin — so those visitors are missing from your server stats.

GA4 works differently. A small piece of JavaScript loads in each visitor's browser and reports the page view directly to Google. That means:

The trade-off is that GA4 counts only visitors who run JavaScript, so it will not include most bots and crawlers. For human traffic — the audience that matters for most sites — it is the reliable source.

Step 1: Create a GA4 Property

  1. Go to analytics.google.com and sign in with your Google account.
  2. Click Admin (the gear icon), then CreateProperty.
  3. Enter a property name (usually your website name), then set your time zone and currency.
  4. Answer the short business questions and click Create.
  5. When prompted to set up a data stream, choose Web, enter your website URL and a stream name, then click Create stream.

Step 2: Copy Your Measurement ID

After the web data stream is created, GA4 shows a Measurement ID in the format G-XXXXXXX. You can find it again any time under AdminData streams → your stream. Copy this ID — you will need it for the tracking snippet.

Step 3: Install the gtag.js Snippet

The most direct way to install GA4 is to add the Google tag (gtag.js) snippet to the <head> of every page. Paste it as high in the <head> as possible, and replace G-XXXXXXX with your own Measurement ID:

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

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

If you manage a static site, add the snippet to each page's HTML template. You can edit your files in the cPanel File Manager or over FTP.

Tip If your site uses a shared header or template file, add the snippet there once so it is included on every page automatically. Placing it in the <head> ensures the tag loads early and captures the page view.

Step 4: Or Use a Plugin or Tag Manager

If you would rather not edit code by hand, you have easier options:

These approaches are ideal if you expect to add more tags later or want to avoid editing templates directly.

Step 5: Verify in Realtime

  1. Open your website in a browser (an incognito window helps avoid cached versions).
  2. In Google Analytics, go to ReportsRealtime.
  3. Within a minute or so you should see at least one active user — that is you.

If nothing appears, confirm the Measurement ID is correct, that the snippet is in the <head>, and that no ad or tracking blocker is active in your test browser. Clear your cache or CDN cache if you edited a cached template.

Warning Analytics that track visitors may trigger privacy and cookie-consent obligations depending on your audience and location (for example the GDPR in the EU or the CCPA in California). You are responsible for displaying an appropriate privacy notice and, where required, obtaining consent before analytics cookies load. Review Google's terms and your local rules, and consider a consent banner that gates the tag.

Combining GA4 with cPanel Stats

GA4 and the built-in cPanel Metrics tools complement each other. Use GA4 for trustworthy human-visitor counts, audience insight, and conversions; use the cPanel Raw Access logs and error tools for the complete server-side record, bot activity, and troubleshooting. Together they give you the full picture of what is happening on your site.