Skip to content
All posts
AnalyticsWordPressGuide

Add cookieless analytics to a WordPress site

The three places to put the tag ranked by how well they survive updates, why page caching is not a problem, and how to track form submissions — no consent banner for the analytics itself.

DA Orbit

WordPress gives you three places to put an analytics tag. One is right, one is fragile, one is fine if you already have the plugin. All three are cookieless here, with no consent banner to configure.

The three ways, ranked

  • A header/footer plugin. If you already run one (WPCode, Insert Headers and Footers, or similar), paste the tag into the footer box and you are done. Nothing to maintain.
  • A child theme or small custom plugin. The clean way if you do not want another plugin. Survives theme updates.
  • Editing the active theme's header.php directly. Works, but the next theme update overwrites it. Avoid.

Header/footer plugin

Paste this into the plugin's footer field (not the header field — the footer keeps it off the critical path):

footer snippet

<script async src="${site.api}/tracker.js" data-site="YOUR_SITE_KEY"></script>

Child theme or custom plugin

Hook wp_footer and print the tag. Put this in a child theme's functions.php or a one-file plugin so a parent theme update cannot remove it.

functions.php

// In your theme's functions.php, or a small custom plugin.
// A child theme or plugin means a theme update will not wipe it.
add_action('wp_footer', function () {
  ?>
  <script async src="${site.api}/tracker.js" data-site="YOUR_SITE_KEY"></script>
  <?php
});

Page caching is fine

The tag is static markup with no server-rendered values, so WP Rocket, W3 Total Cache, LiteSpeed and a CDN all serve it correctly from a cached page. No cache exclusions needed.

Tracking form submissions and other goals

Most WordPress conversions are a form submit. If your form plugin redirects to a thank-you page, put a one-line script on that page. If it shows an inline confirmation, add the script to the confirmation message's HTML.

thank-you page

<!-- On a "thank you" page, or in a form plugin's confirmation HTML -->
<script>
  window.quantalog && window.quantalog("lead_submitted");
</script>

For form plugins that fire a JavaScript event on success (Gravity Forms, WPForms, Contact Form 7), you can listen for that event and call window.quantalog from it instead of relying on a redirect.

The consent banner question

The tracker sets no cookies, so it adds nothing you need to disclose or block behind consent. A stock WordPress install with this tag and nothing else may not need a banner at all. The moment you add a plugin that sets cookies — many embed and marketing plugins do — the banner is back, and it covers the whole site. See do you need a cookie banner for analytics .

💡

Scheduled reports

the SEO audit

Try Quantalog on your own site

One script tag, no cookies, live numbers in about three seconds. Free forever on the Hobby plan.

Start free

Keep reading