Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Affiliate click ID (irclickid, ref) lost on redirect: how to fix

TRK-260High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Affiliate and partner networks tag each click with an ID in the link, for example https://example.com/?irclickid=ABC123 (Impact) or https://example.com/?ref=partner42 (many referral tools). Your affiliate script reads that value from the URL on arrival and stores it in a cookie or in local storage. At purchase time the stored ID is sent back to the network so the partner gets paid.

Where the click ID is lost
  1. Partner link/?irclickid=ABC123
  2. RedirectSends visitor to / without the query string
  3. Affiliate scriptNo click ID found, nothing stored
  4. PurchaseOrder has no partner attached
  5. CommissionPartner is not credited

The redirect drops the query string, so every later step has no partner to credit.

Why it costs you leads or sales

Partner clicks vs credited salesExample numbers
Partner clicks vs credited sales (example)Sales driven by partner: 100 sales; Credited, redirect strips ID: 8 sales; Credited, redirect fixed: 97 sales03877100897Sales driven by partn…Credited, redirect st…Credited, redirect fi…sales

Example: 100 sales really came from one partner. With the redirect stripping the click ID, almost none are credited.

A redirect removes the click ID

The visitor arrives with the ID, the redirect drops it, and the affiliate script has nothing to save.

How to check if your site has it

Test your affiliate entry URLs by hand
  1. Build a test URL

    Take a real landing URL and add a fake ID, for example https://example.com/?irclickid=TEST123&ref=TEST123. Test every variant partners might use: http, https, with and without www, with and without a trailing slash.

  2. Open it in a private window

    Paste the URL and press Enter. Look at the address bar when the page settles. If irclickid and ref are gone, a redirect removed them.

  3. See the redirect chain

    Open DevTools, go to the Network tab, tick Preserve log and reload. Click the first request and read the Location header of each 301 or 302 response. Find the hop where the query string disappears.

  4. Or use curl

    Run the command below and compare the Location headers with your original URL.

  5. Check the stored value

    In DevTools open Application, then Cookies and Local Storage. Confirm your affiliate script saved the test ID. If it did not, the ID was lost or the script is missing.

Follow the redirect chain and show each hopbash
curl -sIL "https://example.com/?irclickid=TEST123&ref=TEST123" | grep -iE '^(HTTP|location)'

How to fix it

Keep the query string on redirects
  1. Find the redirect source

    Check redirect plugins (Redirection, Rank Math, Yoast Premium, Safe Redirect Manager), your host's redirect settings and .htaccess. Disable one at a time and retest.

  2. Pass the query string

    In Redirection, edit the rule and set Query Parameters to 'Pass - ignore but pass parameters to the target'. In Rank Math, enable the option to keep query strings if offered, or switch the rule to a regex that appends $1.

  3. Check the homepage and www rules

    Under Settings > General, make sure WordPress Address and Site Address match the live domain so WordPress does not add a canonical redirect that drops parameters.

Apache: force https and keep the query stringhtaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
nginx: redirect www to non-www and keep the query stringnginx
server {
  listen 443 ssl;
  server_name www.example.com;
  return 301 https://example.com$request_uri;
}
Keep parameters in a JavaScript redirectjavascript
// Before: window.location.href = 'https://example.com/offer';
window.location.href = 'https://example.com/offer' + window.location.search + window.location.hash;
Save the click ID before anything else runsjavascript
(function () {
  var params = new URLSearchParams(window.location.search);
  ['irclickid', 'ref'].forEach(function (key) {
    var value = params.get(key);
    if (value) {
      document.cookie = key + '=' + encodeURIComponent(value) + '; path=/; max-age=2592000; SameSite=Lax';
    }
  });
})();

How to confirm it's fixed

Confirmation checks
  • Open each test URL variant (http, https, www, non-www, with and without trailing slash) with ?irclickid=TEST123&ref=TEST123 and confirm both parameters remain in the address bar.
  • Run the curl command and confirm every Location header includes the query string.
  • In DevTools > Application, confirm the click ID is saved in a cookie or local storage.
  • Complete a test order if your network or store supports a test mode, and confirm the click ID reaches the order or the network's dashboard.
  • Ask the partner or check the network dashboard to confirm a test click is recorded.
Entry URL behaviour

Before the fix

  • `/?irclickid=ABC123` redirects to `/`
  • Affiliate script finds no ID
  • Orders arrive as direct traffic
  • Partners report zero conversions

After the fix

  • `/?irclickid=ABC123` keeps the full query string
  • ID is saved on arrival
  • Orders carry the partner ID
  • Commission is credited

How to prevent it happening again

Prevention habits
  • Keep a short list of affiliate entry URLs and retest them after any change to redirects, domains, SSL, themes, plugins or the CMS.
  • Test after a site migration, a domain change or a new landing page.
  • Give partners the final URL, not one that redirects.
  • Document which redirect rules exist and who owns them.
  • Compare partner-reported clicks against your credited sales each month so a sudden drop stands out.

How FunnelGuard handles this

Questions people ask

Why is my irclickid missing after the page loads?

A redirect is most likely dropping the query string before your affiliate script runs. Common sources are http to https rules, www redirects, trailing-slash rules and redirect plugins. Open the URL with a test irclickid and check the Network tab to find the hop where it disappears.

How do I keep URL parameters on a redirect?

Configure the redirect to pass the query string. In Apache add the QSA flag, in nginx use return 301 https://example.com$request_uri, and in redirect plugins choose the option that passes parameters. In JavaScript, add window.location.search to the new URL.

Why are my affiliates not getting credit for sales?

The click ID may never reach your site's tracking, often because a redirect strips it. Other causes are a missing affiliate script, a cookie set on the wrong domain, or a missing conversion pixel. Test the entry URL with a fake ID first, as it is the quickest check.

Does a 301 redirect remove query parameters?

Not by default in every system, but many rules and platforms do. Server rules that point to a fixed target, and tools such as Shopify, Webflow and Wix URL redirects, send visitors to the new address without the original parameters. Always test with a real query string.

Can I save the affiliate ID in a cookie myself?

Yes, a script can read irclickid or ref from the URL and store it in a first-party cookie as a backup. It only works if the ID is still in the URL when the script runs. Your network may require its own script to handle credit, so follow its documentation.

How do I test affiliate tracking without real clicks?

Add a fake ID such as ?irclickid=TEST123 to your landing URL and check that it survives the redirects and gets stored. Use the network's test mode or a test order if available. Do not generate fake clicks on live partner links.

Can FunnelGuard detect a lost affiliate click ID?

Partly. It checks that configurable persistence keys, such as UTMs and the parameters you add, survive redirects on the journeys you set up. It does not confirm the affiliate network recorded the click or paid a commission.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: utm persistence keys configurable.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.