Do I need a plugin to add privacy-friendly analytics to WordPress?

No. PostDeploy Analytics is one script tag, so WordPress only needs a way to print it in the head of every page. Use your theme's header code setting if it has one, or a few lines in a child theme. A code snippets plugin also works if you already use one.

Last updated 26 November 2026. By Paul Badarau.

A fictional food blog runs WordPress with a page cache. The author wants the snippet on every public page and no new plugin on the site.

  1. Copy the snippet from the Project's tracking setup in Analytics.
  2. If your theme or host has a field for code in the page head, paste the snippet there and skip to step 4.
  3. Otherwise, add this to your child theme's functions.php, with your own snippet in place of the tag: add_action('wp_head', function () { echo '<script defer src="…/script.js" data-site="your-project-id"></script>'; }); Use a child theme, because an update to the parent theme replaces its files and your edit with them. Block themes call wp_head too.
  4. Clear the page cache, or cached pages keep serving HTML without the tag.
  5. Make sure the Project lists every hostname the blog answers on, such as example.com and www.example.com. Pageviews from a hostname the Project does not list are refused.
  6. Open the blog logged out and run the collection check.

The hook prints the tag for you as well while you are logged in. To leave your own visits out, put the echo in the else branch of if (is_user_logged_in()).

Goals need no plugin either. If the contact form sends people to /thank-you, add a goal in PostDeploy Analytics with the matching rule Exact page path and that path.

Optimization and security plugins sometimes combine, delay or rewrite scripts. The Analytics script reads its Project id from the data-site attribute on its own tag, so a rewritten tag can stop it from sending anything. If the check shows no event, view the page source, compare the tag with the snippet, and exclude it from script optimization.

The product page for this is Analytics.

Start your 14-day free trial