NEUAGEOPS
Health + Wellness · Operations
Affiliate · Implementation Guide
Refersion · Formsite · Salesforce · WordPress

Tracking affiliate sign-ups from the referral click to a confirmed Refersion conversion.

How a referral becomes a tracked, payable conversion across our stack — the moving parts, the one dependency that quietly breaks attribution, and the exact setup for Formsite, the WordPress success page, and the affiliate landing pages.

Scope  All affiliate /rfsn pages Stack  WordPress · Formsite · Salesforce · Refersion Status  Implementation
1 Overview

The full path, end to end

A visitor arrives through an affiliate link, fills out the lead form, and lands on a thank-you page. Behind that simple experience, five systems hand off to each other. Here is the order of operations.

1 · Click
Affiliate link
Visitor lands on /rfsn{ID}/. Refersion's pixel records the click.
2 · Capture
Formsite form
Lead submits. A hidden field stores the submitting page URL.
3 · Route
Salesforce
Formsite posts the lead into Salesforce (already live).
4 · Redirect
Success page
Formsite redirects to /affiliate-success/ with the values in the URL.
5 · Convert
Refersion
The success page fires the conversion and credits the affiliate.

Steps 3 and 5 are independent: Formsite's server-side post to Salesforce happens regardless of what the browser does next. The browser redirect (step 4) is what carries the data to the page that fires the Refersion conversion.

2 How attribution actually works

Two scripts, two jobs

Refersion's client-side model is two separate scripts. Understanding which does what is the difference between a flow that works and one that silently credits no one.

ScriptWhat it does
Script 1 — Loader pixelRuns on every page. When a visitor arrives via an affiliate link, it records the click and stores the referral. It also fires the refersion-loaded event.
Script 2 — ConversionRuns on the success page. Listens for refersion-loaded, then calls sendConversion(), which credits whatever affiliate the click stored.
The key point: the conversion does not read an affiliate ID we hand it. It honors the stored click. So the conversion only credits an affiliate if a click was registered first. This is by design — it is how Refersion prevents fraudulent self-crediting.
3 The dependency to verify

Path-based links vs. the tracked click

Refersion registers a click when a visitor arrives with the tracking value Refersion expects — normally a query parameter like ?rfsn=.... Our affiliate pages use a path (/rfsn9108109/), not a query parameter. The standard pixel does not read a path segment as a referral.

So the first thing to confirm is simple: what link are affiliates actually sharing?

If affiliates share…Then…
A real Refersion link that redirects into /rfsn{ID}/The click is already tracked. The success page conversion will work as-is.
The bare path URL (neuagehealthwellness.com/rfsn9108109/)No click registers by default. Use the landing-page snippet in Section 6 to turn the path into a tracked click.
4 Formsite

Redirect the form to WordPress, carrying the data

Because the success page lives on WordPress, Formsite pipe codes do not resolve there. Instead, Formsite hands the values across as URL query parameters on the redirect. Pipe codes are substituted at redirect time.

  1. In the Form Editor, click each field you want to send and read its pipe code in the bottom-right of its settings (it looks like [pipe:3]). Collect the codes listed in the table below.
  2. Go to Form Settings → Success Pages and set the success page type to Redirect.
  3. Set the destination URL to the template below, swapping in your real field codes.
  4. Save. Formsite's existing post to Salesforce is unaffected and continues to run.
Redirect destination URL
https://www.neuagehealthwellness.com/affiliate-success/?fname=[pipe:3]&lname=[pipe:4]&email=[pipe:5]&ref=[pipe:reference]
FieldPipe codeUsed for
First name[pipe:?]Greeting on the page + Refersion customer record
Last name[pipe:?]Refersion customer record
Email[pipe:?]Refersion customer record + later email matching
Reference #[pipe:reference]Unique order_id (see Section 8)
Submitting URL (hidden)[pipe:?]Stays in Salesforce for affiliate attribution / server-side backstop — not passed to the page
Encoding check: if a submitter's name contains a space or apostrophe, confirm Formsite encodes it in the redirect so the query string does not break. Test once with a two-word name. The page reads values defensively and will not error, but a name could display oddly if it is not encoded.
5 WordPress success page

The page Formsite redirects to

Page: /affiliate-success/  ·  Editor: Elementor

Because this page is on the same domain as the click pixel, Refersion's first-party tracking works natively — no cross-domain bridging. The script reads the values from the redirect URL and fires the conversion.

  1. Edit /affiliate-success/ in Elementor. Drag an HTML widget into a full-width section; set the section to Stretch and remove top/bottom padding.
  2. Paste the companion file NEUAGE_Affiliate_Success_Page_WordPress.html in full. It includes the branded confirmation card, the on-page name/email personalization, and the conversion script.
  3. Save, then purge NitroPack so the widget's script is actually served (NitroPack will otherwise strip or cache the prior state).

The functional core — the part that matters for QA — is below. The companion file wraps this with the styled card.

Conversion script (reads the redirect query string)
<script>
(function () {
  var q = new URLSearchParams(window.location.search);
  var FIRST_NAME = q.get("fname") || "";
  var LAST_NAME  = q.get("lname") || "";
  var EMAIL      = q.get("email") || "";
  var REFERENCE  = q.get("ref")   || "";

  // unique order id — Refersion rejects duplicates, so never hardcode
  var ORDER_ID = REFERENCE
      ? "NAHW-" + REFERENCE
      : "NAHW-" + Date.now() + "-" + Math.floor(Math.random() * 1e6);

  document.addEventListener("refersion-loaded", function () {
    r.addTrans({ "order_id": ORDER_ID, "currency_code": "USD" });
    r.addCustomer({ "first_name": FIRST_NAME, "last_name": LAST_NAME, "email": EMAIL });
    r.addItem({ "sku": "Affiliate-Lead", "quantity": "1", "price": "0" });
    r.sendConversion();
  });
})();
</script>
6 Affiliate landing pages

Turning the path into a tracked click

Only needed if affiliates share the bare path URL (see Section 3). Place this in an HTML widget at the top of each /rfsn{ID}/ page, above the Refersion loader, so it runs first. It reads the ID from the path and writes ?rfsn= into the URL so a click can register.

Landing click-registration snippet
<script>
(function () {
  // bare numeric id, OR "." + code if your Refersion account requires a compound token
  var TOKEN_SUFFIX = "";
  try {
    var params = new URLSearchParams(window.location.search);
    if (!params.get("rfsn")) {
      var m = window.location.pathname.match(/rfsn(\d+)/i);
      if (m) {
        params.set("rfsn", m[1] + TOKEN_SUFFIX);
        var newUrl = window.location.pathname + "?" + params.toString() + window.location.hash;
        window.history.replaceState(null, "", newUrl);
      }
    }
  } catch (e) {}
})();
</script>
Confirm with Andre / the Refersion dashboard first: Refersion tracking tokens are sometimes a compound value (id.code), not the bare numeric ID. If our account expects a compound token, the bare number will not match an affiliate and no click will register. Verify the exact ?rfsn= value Refersion generates for affiliate 9108109 and mirror that format in TOKEN_SUFFIX.
7 The loader rule

One loader, consistent settings

The conversion depends on the loader pixel (Script 1) existing on the success page — that is what defines r and fires refersion-loaded. Two rules keep this clean.

  1. Do not double-load. If the loader is in our global header template, it is already on /affiliate-success/. Leave the loader block in the success page file commented out. A second loader can double-fire.
  2. Match settings. If the success page does need its own loader, paste our existing site loader verbatim. The pubKey and the first-party setting must match the rest of the site, or the stored click cannot be read.
8 Order ID

Why it must be unique every time

Refersion rejects a duplicate order_id and will fail to attribute. We use the Formsite result reference number (NAHW-<reference>), which is unique per submission and ties the conversion back to a real, auditable record. If the reference is ever missing, the script falls back to a timestamp plus a random suffix so it never collides.

Do not hardcode the order ID or reuse a fixed number. Sending the same value twice causes a Refersion error and a lost conversion.
9 QA & testing

How to confirm it works before trusting it

  1. Temporarily enable Refersion debug mode (uncomment the dbg_mode line noted in the file).
  2. Run a full referral end to end: click a real affiliate link, complete the form, follow the redirect to the success page.
  3. Open the browser console. You are looking for the [NAHW] Refersion conversion sent log and Refersion's own debug output confirming an affiliate is attached.
  4. Confirm the conversion appears in the Refersion dashboard against the correct affiliate.
  5. Turn debug mode back off for production.
Reading the result: if the conversion sends but no affiliate is attached, the click never registered. That points straight back to Section 3 and Section 6 — confirm the link format affiliates share and the token format with Andre.
10 Reliability

The honest limitation, and the backstop

Client-side Refersion cannot force-credit a specific affiliate — it only honors a tracked click. For path-based pages that is a genuine fragility. The durable answer is server-side.

Server-side backstop: push the conversion from Salesforce to Refersion via API, force-crediting the affiliate ID parsed from the stored submitting URL with the regex rfsn(\d+) — the same pattern the success page already runs. Salesforce already holds that URL, so no extra data needs to travel through the browser.

Belt and suspenders: run both. Client-side for instant attribution when a click is tracked, server-side as the authoritative record, deduplicated on order_id.

11 Open items & owners

What's left to lock down

ItemOwner / source
Confirm the exact link affiliates share (real Refersion link vs. bare path)Internal
Confirm the Refersion tracking token format (bare ID vs. id.code)Andre (Refersion)
Decide the payable event: form submission vs. downstream Salesforce qualificationInternal
Retrieve Refersion API credentials for the server-side backstopAndre / account settings
Confirm deduplication on order_id if running both pathsInternal