Link Decoration for form

gerard_reyes Posted by: Gerard Reyes Date Posted: September 23, 2026
Back to Case Studies

Issue

A redirect form does not carry over attributions. Link Decoration normally works only for anchor elements. But there is no anchor element when moving over to a different domain URL only a form redirection is available.

Solution

Added a code to pass the attributions via form action by replicating Link Decoration in anchor’s behavior.

//https://app.webfx.com/todos/269669589
(function () {
setTimeout(function () {
mcfx(function (tracker) {
var attempts = 0;
var maxAttempts = 3;
var interval;

function run() {
var form = document.getElementById('address-form');
attempts++;

if (!form) {
console.log('RCFX address-form not found, attempt ' + attempts);
if (attempts >= maxAttempts) {
clearInterval(interval);
}
return;
}

clearInterval(interval);
console.log('RCFX address-form tracking fields');

var values = tracker.session._values;
var attribution = values.get('attribution') || {};

var fields = {
fx_sid: values.get('sid'),
fx_lp: values.get('lp'),
fx_uid: values.get('uid'),
fx_gaId: values.get('gaId'),
fx_s: attribution.source,
fx_m: attribution.medium,
fx_ch: attribution.channel,
fx_sc: attribution.subchannel
};

console.log('RCFX field values', fields);

for (var name in fields) {
if (!fields.hasOwnProperty(name)) continue;
var input = form.querySelector('input[name="' + name + '"]');
if (!input) {
input = document.createElement('input');
input.type = 'hidden';
input.name = name;
form.appendChild(input);
}
var value = fields[name];
input.value = (value === null || value === undefined) ? '' : value;
}
}

run();
interval = setInterval(run, 1000);
});
}, 1000);
})();

 

Achievement

Link Decoration worked for the form, so it passed attribution via the form action without relying on anchor elements.

Snippet/Screenshot/Link

Task: Link

Code: Screenshot