Skip to content

Dynamic landing page tracking links for several tracking domains

You may point several domains (for example CNAME records) at your FunnelFlux server and send traffic to the same lander through each of them. This page shows how to make the lander’s action links use the tracking domain that sent the visit. It does not cover creating the DNS records themselves.

FunnelFlux can use an unlimited number of tracking domains, for every part of tracking except the domain you log in on to view your data.

Cookies are the problem with more than one domain.

If the tracking link uses domain1.com and sends the visitor to somelander.com, the action links on that lander also need to use domain1.com. Otherwise FunnelFlux cannot read the cookies, and it does not know the visitor ID or the earlier history.

Without that cookie, FunnelFlux does not know who the visitor is or which funnel they are in.

An action link with extra parameters can declare the current node and funnel, which is enough to track and redirect organic clicks. That does not solve the case of several tracking domains sending traffic to the same lander, with the visitor data staying consistent after the click.

Find-and-replace can swap one domain for another in the HTML when you move from one domain to a new one. That is slow, and it does not help when many domains are in use at once.

Pass the tracking domain to the lander in the URL, and have the lander rewrite its outgoing links to that domain. One lander can then serve every tracking domain.

Pass the tracking domain with the {flux-domain} token.

Append this to lander and offer URLs as needed:

...&ffdomain={flux-domain}

The script below reads ffdomain from the page URL and swaps the domain in every link and iframe that contains flux_action. It is plain JavaScript and needs no library. It also rewrites links that other scripts add to the page later.

Add it near </body>, so it runs after the page elements exist:

<script>
(function () {
var oldDomain = 'old.com';
var newDomain = new URLSearchParams(window.location.search).get('ffdomain');
if (!newDomain) return;
function changeLinks(selector, attribute) {
document.querySelectorAll(selector).forEach(function (el) {
var value = el.getAttribute(attribute);
if (value && value.indexOf('//' + oldDomain) !== -1) {
el.setAttribute(attribute, value.replace('//' + oldDomain, '//' + newDomain));
}
});
}
function changeAllActionLinks() {
changeLinks('a[href*="flux_action"]', 'href');
changeLinks('iframe[src*="flux_action"]', 'src');
}
changeAllActionLinks();
new MutationObserver(changeAllActionLinks).observe(document.body, {
childList: true,
subtree: true,
});
})();
</script>

Set old.com to the tracking domain hard-coded in the HTML today. Use the full domain, such as sub.domain.com, not only the registrable domain.

With this code on the page, and ffdomain passed in the URL, outgoing action links and iframe sources point at the tracking domain that sent the visit, so FunnelFlux can read its cookies.