Install

Add analytics and revenue attribution to WordPress

You don't need a plugin for this, and you probably shouldn't use one: a plugin to insert one script tag is more code, more updates, and more attack surface than the tag it inserts. Two lines in your child theme do it properly.

Start a 14-day trialLast reviewed August 2026
  1. Enqueue the script from your child theme

    Add this to functions.php in your CHILD theme, not the parent — parent theme edits are overwritten on the next update. wp_enqueue_script with the right arguments produces a deferred tag with the data attribute intact.

    wp-content/themes/your-child-theme/functions.php
    add_action('wp_enqueue_scripts', function () {
      wp_enqueue_script(
        'revtrail',
        'https://revtrail.pyln.dev/track.js',
        [],
        null,
        ['strategy' => 'defer', 'in_footer' => false]
      );
    });
    
    add_filter('script_loader_tag', function ($tag, $handle) {
      if ($handle !== 'revtrail') return $tag;
      return str_replace('<script ', '<script data-site="SITE_KEY" ', $tag);
    }, 10, 2);
  2. Or paste it, if you'd rather not touch PHP

    Any 'insert headers and footers' facility your theme already provides works — paste the tag into the header field. Use this if you don't have a child theme; just be aware that theme-builder header fields are sometimes stripped by caching or optimisation plugins.

    theme header field
    <script defer src="https://revtrail.pyln.dev/track.js" data-site="SITE_KEY"></script>
  3. Confirm it's receiving

    Open your site in a normal browser tab, then check Realtime in the Revtrail dashboard — your own visit should appear within a few seconds. If nothing arrives, the usual causes are a mistyped site key, an ad blocker on your own browser, or a Content-Security-Policy that blocks the script origin.

  4. Track the conversion, whatever it is

    A contact form, a WooCommerce add-to-cart, a newsletter signup, a course purchase. Fire revtrail('signup') at the success moment — most form plugins expose a JavaScript success event you can hook.

Caching plugins and why the numbers look wrong

Page caching serves a stored HTML document to visitors, which is fine — the script tag is in the cached HTML and runs in each visitor's browser. What breaks things is aggressive JavaScript optimisation: combining, deferring, or lazy-loading third-party scripts can strip the data-site attribute or delay execution until after the visitor leaves. If your numbers look implausibly low, exclude the tracker from your optimisation plugin's JS handling first.

WooCommerce revenue

Where WooCommerce settles through Stripe, point that Stripe webhook at Revtrail and order revenue arrives verified. The thank-you page can also fire a named event for the conversion count, but the amount should come from the webhook — a number typed into a template is a number someone can change.

Why not a plugin

Plugins that exist to insert one line of HTML bring an update cadence, a settings page, a database option, and occasionally a vulnerability. The functions.php snippet above is the whole integration and it can't break on someone else's release schedule.

Questions people actually ask

Is there an official Revtrail WordPress plugin?
No, deliberately. The install is one script tag; a plugin would add more code than it inserts.
My numbers dropped after installing a speed plugin. Why?
JavaScript optimisation features commonly combine or delay third-party scripts, which can strip the data-site attribute or stop the script running at all. Add the tracker to that plugin's exclusion list.
Do I need a cookie banner for this?
Not for Revtrail. The default identity is a daily rotating hash — no cookies, no persistent identifier, nothing stored on the device. If you run ad pixels or other analytics that do use cookies, their obligations are unchanged.
Will this slow my site down?
The script is deferred, so it never blocks rendering, and it's about 3KB over the wire gzipped. It fires one beacon per pageview.

Install guides

All install guides