All articles Guide

A Google Analytics alternative for WordPress: add privacy-friendly stats in 10 minutes

Replace Google Analytics on a WordPress site with cookie-free analytics. Add one script without editing theme files, keep your caching plugin happy and check it works.

We make Tidemark, so we are not a neutral party. We have tried to be fair, to say where other tools are the better choice, and to keep claims about other products to things you can check yourself.

WordPress sites often end up with Google Analytics through a plugin that adds a cookie banner, a settings page and a lot of tracking nobody asked for. You can swap that for a small, cookie-free script in about ten minutes, with no theme editing and no extra analytics plugin.

This guide uses Tidemark, but the steps are the same for any tool that gives you a single script tag.

Before you start

You need a Tidemark site (hosted on Tidemark Cloud or self-hosted) and access to your WordPress admin. In Tidemark, add your domain under Add site and copy the snippet. It looks like this:

<script defer data-domain="yourdomain.com" src="https://app.tidemarkanalytics.com/js/script.js"></script>

If you self-host, the src points at your own Tidemark address instead.

Step 1: Add the script without touching theme files

Editing header.php is fragile, because a theme update can wipe your change. Use a header-and-footer snippet plugin instead. Plugins such as WPCode or Insert Headers and Footers are common choices.

  1. Install and activate the plugin.
  2. Open its settings and find the Header (or “Scripts in Header”) box.
  3. Paste the Tidemark snippet and save.

Block themes and some page builders have their own “custom code” area that does the same job. If yours does, use it.

Step 2: Remove Google Analytics

Delete the old tag in whatever added it: the Google Analytics plugin, a “Site Kit” setup, or a snippet in your theme. Running both for a couple of weeks is useful for comparing numbers, but remove Google Analytics when you are done so you can drop the cookie banner if it only existed for analytics. Keep it if other tools on your site still set cookies.

Step 3: Check it works

  1. Open your site in a private window.
  2. Open the Tidemark dashboard and look at current visitors. You should see yourself within a few seconds.
  3. Click around, and confirm the pages show up under Top pages.

If nothing appears, view the page source and search for data-domain. If it is missing, a caching plugin may still be serving the old page.

Caching and optimisation plugins

  • Clear the cache after adding the script, so visitors get the new page.
  • Do not defer or combine the script in a way that rewrites it. Most optimisation plugins can exclude a script by its address, so add your Tidemark address to the exclude list if you see missing visits.
  • CDN and ad blockers: some blockers hide analytics scripts. You can reduce that by serving the script from your own domain through a proxy and setting data-api to match. The Tidemark docs explain the setup.

Tidemark can count outbound link clicks, file downloads and form submissions by changing the script file name, for example script.outbound-links.file-downloads.js. This guide covers the options.

What about the old data?

Google Analytics history cannot be imported into Tidemark. Export the reports you want to keep, and treat the switch date as the start of the new data. Here is a longer migration checklist.

More from the blog