Guide SEO & Marketing

How to set up website analytics

Adding the tracking code is the easy part. Here is what to decide first and how to check it is actually working.

Updated 7 min read Beginner

Search Console tells you how your site performs in Google's results. Analytics tells you what happens after somebody clicks through: which pages they land on, how long they stay, and whether they do anything you care about once they arrive. The two answer different questions, and most sites benefit from having both.

Choosing a tool before you install anything

The decision that actually matters here is which tool to use, not how to paste in a script tag — that part is nearly identical across all of them.

OptionGood fit whenTrade-off
Google AnalyticsYou want detailed behaviour data and easy integration with Search Console and Google AdsFree, but sets cookies and typically needs a consent mechanism, and its depth can be overkill for a simple site
A privacy-focused, cookieless alternativeYou want basic traffic numbers without a consent banner, or you are wary of sending visitor data to a large third partyUsually a paid or self-hosted product, with less depth than Google Analytics offers
Your control panel's built-in statisticsYou want the roughest possible sense of traffic with zero setupBasic server-log-based numbers, no behavioural detail, no way to see individual page journeys

There is no universally correct choice. A small brochure site with no advertising budget may get everything it needs from the basic statistics already included in its control panel. A site that is actively being marketed, tested, and iterated on benefits from the depth Google Analytics or a similar dedicated tool provides.

Getting the code onto every page

Whichever tool you choose, the mechanism is the same: it gives you a small snippet of JavaScript that has to load on every page you want measured, normally placed just before the closing </head> tag.

  • On a CMS such as WordPress, a dedicated plugin for your chosen tool is almost always the right way to add this — it inserts the code sitewide, including on pages you add later, without editing template files by hand.
  • On a hand-coded or static site, the snippet has to be pasted into the shared header include or template that every page uses. Adding it to one page only measures that one page.
  • Through a tag manager, if you already use one, the analytics snippet can be deployed and updated centrally without touching your site's code again for future changes.
One tracking code, not several

Installing a plugin's built-in analytics and also manually pasting the same code again is a common mistake, and it inflates every number by counting each visit twice. If you switch tools or plugins, remove the old snippet completely rather than leaving it running alongside the new one.

Confirming it is actually working

Do not wait for the standard reports to populate before checking your work — most take up to a day to show meaningful data, which is far too long a feedback loop for catching a mistake. Instead, open the tool's real-time report, then visit your own site in another tab. If the code is correctly installed, your visit should appear within seconds. If it does not, view the page's source code directly and search for the tracking ID to confirm the snippet is actually present on the live page rather than saved in a setting that never rendered.

Keeping your own visits out of the numbers

Once analytics is running, your own day-to-day use of the site — testing changes, checking pages, showing it to colleagues — becomes noise in the data if it is not excluded. Most tools offer a way to filter out a known IP address, and browser extensions exist that block a specific analytics tool from recording your own visits at all. This matters more than it sounds: on a low-traffic site, a handful of daily visits from the person building it can visibly distort which pages appear busiest.

Decide what a "conversion" is before you need the answer

Traffic numbers alone rarely tell you whether a site is working. Deciding in advance what counts as a meaningful outcome — a form submission, a newsletter signup, a purchase — and configuring it as a tracked event or goal turns a wall of visit counts into a number you can actually act on.

Whichever tool ends up installed, treat the first few days of data with a degree of caution rather than drawing firm conclusions immediately — a small sample, your own testing traffic still working its way out of the numbers, and simple day-to-day variation can all make an early reading look more dramatic than it turns out to be once a few weeks of data have accumulated.

Analytics only becomes useful once you have a habit of looking at it. Checking in occasionally, rather than only after something has gone visibly wrong, is what makes a sudden change in the numbers — good or bad — something you notice while it is still worth investigating. See what to check when traffic suddenly drops for what to do when the numbers move the wrong way.

Frequently asked questions

Do I need a cookie consent banner if I install Google Analytics?

In most jurisdictions with cookie or privacy laws, yes — standard Google Analytics sets cookies used for tracking, which generally requires consent before they are set. This is a legal question for your specific market and audience, and a privacy-focused, cookieless analytics tool is one way some site owners choose to sidestep it, though you should check what applies to you rather than relying on a KB article for legal advice.

Why does my dashboard show zero visitors when I know people have visited?

Check first that the tracking code is actually present on the live page — view the page source rather than trusting that a plugin setting saved correctly. After that, remember most analytics tools have a short delay before data appears outside the real-time report, so a brand new install can look empty for the first day even when it is working.

Related reading