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.
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.
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.
| Script | What it does |
|---|---|
| Script 1 — Loader pixel | Runs 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 — Conversion | Runs on the success page. Listens for refersion-loaded, then calls sendConversion(), which credits whatever affiliate the click stored. |
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. |
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.
- 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.
- Go to Form Settings → Success Pages and set the success page type to Redirect.
- Set the destination URL to the template below, swapping in your real field codes.
- Save. Formsite's existing post to Salesforce is unaffected and continues to run.
https://www.neuagehealthwellness.com/affiliate-success/?fname=[pipe:3]&lname=[pipe:4]&email=[pipe:5]&ref=[pipe:reference]
| Field | Pipe code | Used for |
|---|---|---|
| First name | [pipe:?] | Greeting on the page + Refersion customer record |
| Last name | [pipe:?] | Refersion customer record |
| [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 |
The page Formsite redirects to
Page: /affiliate-success/ · Editor: ElementorBecause 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.
- Edit /affiliate-success/ in Elementor. Drag an HTML widget into a full-width section; set the section to Stretch and remove top/bottom padding.
- 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.
- 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.
<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>
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.
<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>
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.
- 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.
- 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.
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.
How to confirm it works before trusting it
- Temporarily enable Refersion debug mode (uncomment the dbg_mode line noted in the file).
- Run a full referral end to end: click a real affiliate link, complete the form, follow the redirect to the success page.
- 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.
- Confirm the conversion appears in the Refersion dashboard against the correct affiliate.
- Turn debug mode back off for production.
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.
What's left to lock down
| Item | Owner / 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 qualification | Internal |
| Retrieve Refersion API credentials for the server-side backstop | Andre / account settings |
| Confirm deduplication on order_id if running both paths | Internal |