LuriaDocs
Install

Install on WooCommerce

Put the Luria tag in your store's head with a code plugin, then count purchases from WooCommerce itself with a signed webhook, or on the order-received page.

plain textupdated 2026-10-02

About 10 minutes

Two things to do. The tag goes in the <head> of every page. Then purchases are counted, best from WooCommerce itself (a signed webhook, so refunds flow back and a closed tab loses nothing), or on the order-received page when you cannot add a webhook.

What you'll need

  • Your Luria tag, with your site ID already filled in. Luria gives you the tag during onboarding, or by email from hello@luriart.com. The dashboard does not show the site ID yet.
  • WordPress admin access to the store
  • A code plugin such as WPCode (formerly Insert Headers and Footers), or a child theme you can edit

Steps

Step 1: Put the tag in the head

In WordPress: Plugins → Add New, install and activate WPCode, then open Code Snippets → Header & Footer. Paste the tag into the Header box and click Save Changes.

<script async src="https://luriart.com/snippet.js" data-luria-site="YOUR_SITE_ID"></script>

On a classic theme you can instead paste it into Appearance → Theme File Editor → header.php, just above </head>, in a child theme. Block themes (the default themes since WordPress 5.9) have no header.php, so use the plugin.

Head only. In the footer or the body, the tag still loads, but variants apply after the page has already painted.

First let each order carry the visitor's Luria id. In WPCode add a PHP Snippet, set to run everywhere, then Save and Activate:

add_action( 'wp_head', function () {
  if ( function_exists( 'is_checkout' ) && is_checkout() ) {
    echo '<script>try{var s=localStorage.getItem("luria_sid");if(s)document.cookie="luria_sid="+s+"; path=/; SameSite=Lax; Secure"}catch(e){}</script>';
  }
} );
add_action( 'woocommerce_new_order', function ( $order_id ) {
  $sid = isset( $_COOKIE['luria_sid'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['luria_sid'] ) ) : '';
  if ( ! preg_match( '/^[\w.:-]{1,100}$/', $sid ) ) { return; }
  $order = wc_get_order( $order_id );
  if ( $order ) { $order->update_meta_data( 'luria_sid', $sid ); $order->save(); }
} );

It works with the classic checkout and the checkout block.

Then connect the webhook: follow the WooCommerce preset on Webhooks (Topic Order updated, your Luria URL and signing secret). Luria counts an order once it is processing or completed, credits the split test through luria_sid, falls back to the hashed billing email, and lowers tracked revenue when you refund.

Using the webhook? Skip Step 3, or the order counts twice.

Step 3: Or count the purchase on the order-received page

No webhook possible (no admin access to WooCommerce settings)? WooCommerce sends every paid order to /checkout/order-received/<id>/. That is not one of the paths Luria detects on its own (/thank-you, /thank_you, /orders/<id>), so add the conversion call with the woocommerce_thankyou hook.

In WPCode: Code Snippets → Add Snippet → Add Your Custom Code, choose PHP Snippet, paste this, set it to run everywhere, then Save and Activate. A child theme's functions.php works just as well.

add_action( 'woocommerce_thankyou', function ( $order_id ) {
  $order = wc_get_order( $order_id );
  if ( ! $order ) { return; }
  ?>
  <script>
    (function go(n) {
      if (window.luria) {
        var k = "luria_wc_<?php echo esc_js( $order_id ); ?>";
        if (!localStorage.getItem(k)) {
          localStorage.setItem(k, "1");
          window.luria.convert("purchase", <?php echo (float) $order->get_total(); ?>);
        }
        return;
      }
      if (n < 50) { setTimeout(function () { go(n + 1); }, 200); }
    })(0);
  </script>
  <?php
} );

The tag loads in the background, so the call waits for it, up to about ten seconds. The localStorage key keeps a customer who reloads the page from being counted twice.

Classic checkout and the newer checkout block both land on the order-received page, so the hook fires either way.

Step 4: Clear your cache

WP Rocket, LiteSpeed Cache, WP Super Cache and your host's own cache all serve the old <head> until you purge them. Purge, then reload your home page.

Verify it worked

  1. Open your store in a private window with ad blockers off. If you are in the EU, UK or Switzerland, Luria shows a small consent banner; click Accept, since nothing is tracked before you answer it.
  2. View the page source. The tag is inside <head> and your site ID is in it, not YOUR_SITE_ID.
  3. In the browser's Network tab, look for a request to luriart.com/api/events. Events are batched, so give it a couple of seconds.
  4. Place a test order. On luriart.com/app, open Overview and its Customers section: the Customers count goes up by one and that visit is listed with its source and value.
The Customers section on the Overview tab, with the People who bought table listing each converted visit with source, first seen and value

Full checklist: Verify your install.

Common failures

  • Nothing tracked at all. The tag is missing its site ID, or the ID has a typo. Without a valid data-luria-site the snippet stops immediately.
  • Tag not on the page. A caching plugin is still serving the old head, or you pasted into the Footer box. Purge, then check the source again.
  • Webhook disabled in WooCommerce. WooCommerce turns a webhook off after more than five failed deliveries in a row. Set it back to Active and check the URL.
  • Nothing counted after an order. The PHP snippet is inactive, limited to certain pages, or the store uses a custom thank-you page that does not fire woocommerce_thankyou. Test with a real order, not a preview.
  • Counted twice. Both the webhook and the Step 3 hook are active, the hook is registered twice (plugin and functions.php), or you also call window.luria.convert in a page template. Keep one call per order. See Duplicates.
  • Nothing in the test browser. Global Privacy Control or Do Not Track is on, or you clicked Decline on the banner earlier. Luria collects nothing in both cases. Clear the site data and try again.
  • Blocked by your own site. A Content Security Policy that does not allow Luria stops the script. Add https://luriart.com https://www.luriart.com to script-src and connect-src (both hosts: luriart.com redirects to www).

Next steps

On this page