SEO & Marketing

Adding Google Analytics to Your Website

By the Domain India teamPublished 8 min read
Knowledge base article
Contents (7 sections)

Google Analytics shows how many people visit your website, where they come from and what they do once they arrive. The current version, Google Analytics 4 (GA4), is free and takes about ten minutes to set up. This guide covers creating the account, adding the tracking code to any website or to WordPress, checking that it works, and the privacy basics for Indian site owners.

Key takeaways

Create a GA4 property at analytics.google.com and copy its Measurement ID (it starts with G-). Add the Google tag to the head of every page, or on WordPress use the Site Kit by Google plugin. Open Reports › Realtime and visit your site to confirm data arrives; standard reports fill in within a day or two. If you collect personal data, say so in your privacy policy, and use a consent banner if you have visitors from Europe.

1. What Google Analytics 4 tells you

GA4 replaced Universal Analytics, which stopped collecting data in 2023. Any old tracking ID that starts with UA- no longer works and should be removed. GA4 measures events, such as page views, scrolls and outbound clicks, and groups the reports into four areas:

ReportWhat it answers
AcquisitionWhere visitors come from: Google search, social media, other sites, ads or direct visits
EngagementWhich pages they view, for how long, and what they click
MonetizationPurchases and revenue, if you run a shop and send e-commerce events
RetentionHow many visitors come back, and how often

Actions that matter to your business, such as a contact form submission or a purchase, can be marked as key events (earlier called conversions), so you can see which traffic sources bring real enquiries.

2. Create your GA4 property

  1. Sign in.
    Go to analytics.google.com with the Google account that should own the data. Use a business account you will keep, not a staff member's personal one.
  2. Create an account.
    Click Start measuring, name the account after your business and choose the data-sharing settings.
  3. Create a property.
    Name it after the website, and set the reporting time zone to India and the currency to Indian Rupee.
  4. Add a web data stream.
    Choose Web, enter your site's address (for example https://yourdomain.com) and a stream name. Leave Enhanced measurement on; it tracks scrolls, outbound clicks, site search and file downloads without extra code.
  5. Copy the Measurement ID.
    The stream page shows it, starting with G-. You need it in the next step.

3. Add the tracking code to any website

On the web stream page, open View tag instructions and choose Install manually. Google shows a snippet like this, with your own ID:

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>

Paste it immediately after the opening head tag on every page. On a PHP site that shares a header file (often header.php or a layout template), add it once there. On a plain HTML site, add it to each page. You can edit files with the File Manager in your control panel; see how to use the File Manager.

Using Google Tag Manager?

If you already use Google Tag Manager, don't paste the snippet as well. Add a Google tag in Tag Manager with your G- ID and publish the container. Installing both counts every page view twice.

4. Add Google Analytics to WordPress

Site Kit by Google is Google's official plugin, and the simplest route:

  1. Install the plugin.
    In WordPress, go to Plugins › Add New, search for "Site Kit by Google", then install and activate it.
  2. Run the setup.
    Click Start setup and sign in with the Google account that owns your Analytics property.
  3. Connect Analytics.
    Choose your existing GA4 property, or let Site Kit create one. Site Kit then adds the tag to every page for you.
  4. Check the dashboard.
    Site Kit shows visitor numbers inside WordPress, and can connect Google Search Console too.

If you prefer not to add a full plugin, a header-code plugin such as WPCode can paste the snippet from section 3 into every page. Use only one method: two plugins adding Analytics also double-count.

More WordPress guidance is in Mastering WordPress: a step-by-step guide.

5. Check that it works

  1. Open Realtime.
    In Google Analytics, go to Reports › Realtime.
  2. Visit your site
    from your phone on mobile data, or from a private browser window.
  3. Look for yourself.
    Within a minute or so, one active user should appear, with the page you opened.
  4. Wait for the full reports.
    Standard reports can take 24 to 48 hours to fill in.

If nothing shows:

  • An ad blocker or privacy browser may be blocking Analytics for you only. Test from another device.
  • The page may be cached. On our cPanel servers, a caching layer can serve a copy of a page made before you added the code for up to two hours. Open the page with ?t=1 added to the address to fetch a fresh copy. A WordPress caching plugin may also need its cache cleared.
  • Check the ID. Open the page source (Ctrl+U) and search for G-. The ID must match your data stream exactly.
  • Google Tag Assistant (tagassistant.google.com) shows whether the tag fires on each page.

Analytics sets cookies and collects data about visitors' devices and behaviour. This is general information, not legal advice:

  • India: the Digital Personal Data Protection Act, 2023 (DPDP Act) governs personal data. At minimum, say in your privacy policy that you use Google Analytics and what it collects.
  • Visitors from Europe or the UK: GDPR and cookie rules expect consent before analytics cookies are set. Use a consent banner that supports Google Consent Mode, so tags respect the visitor's choice.
  • Reduce what you collect. In GA4, go to Admin › Data collection and modification › Data retention to set how long user-level data is kept, and never send names, email addresses or phone numbers to Analytics in page addresses or events.
Don't put personal data in URLs

If a form redirects to an address such as /[email protected], that email address is sent to Google Analytics, which breaks Google's terms. Redirect to a plain thank-you page instead.

7. Where Domain India fits

Google Analytics works on any Domain India hosting plan: cPanel, DirectAdmin, Webuzo and Windows hosting all serve your own pages, so you add the tag exactly as above. Nothing needs to be installed on the server.

If you build with the Domain India AI Website Builder, the site has built-in visitor analytics (page views, top pages and traffic sources) with no Google account needed, and the plan page lists Google Analytics support for connecting your own property. If you can't find where to add your Measurement ID, ask support.

For the bigger picture of getting found on Google, including Search Console and sitemaps, read the SEO optimisation guide.

Is Google Analytics free?

Yes. Google Analytics 4 is free for websites of all sizes. A paid enterprise edition exists, but small business websites don't need it.

Where do I find my Google Analytics Measurement ID?

In Google Analytics, go to Admin, Data streams, and open your web stream. The Measurement ID starts with G- and is shown at the top of the stream details.

My old tracking code starts with UA-. Does it still work?

No. Universal Analytics stopped collecting data in 2023. Create a GA4 property, add its G- tag to your site and remove the old UA- code.

How long before data appears in Google Analytics?

The Realtime report shows visits within a minute or so. Standard reports can take 24 to 48 hours to fill in.

Why don't I see myself in the Realtime report?

An ad blocker or privacy browser may be blocking Analytics, the page may be a cached copy made before you added the code, or the Measurement ID may not match. Test from another device, add ?t=1 to the address, and check the page source for your G- ID.

Do I need a cookie banner for Google Analytics?

If you have visitors from Europe or the UK, cookie rules there expect consent before analytics cookies are set, so use a consent banner. For Indian visitors, mention Google Analytics in your privacy policy under the DPDP Act, 2023. This is general information, not legal advice.

How do I add Google Analytics to WordPress?

Install and activate the Site Kit by Google plugin, run its setup, sign in with your Google account and connect your GA4 property. Site Kit adds the tracking tag to every page for you.

Ready to measure your site? Host it on cPanel hosting, build it with the AI Website Builder, or open a support ticket if the tag won't show up.

Need a website to measure?

Describe your business, and AI builds the site with visitor analytics built in.

Try the AI Website Builder

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app