Cross-domain tracking

During your first few weeks on Flip.to's Discovery, we conduct A/B tests that rely on cross-domain tracking to measure results accurately. Discovery supports this tracking out-of-the-box. For the Control (your current booking flow without Discovery), you may need an additional snippet of code to set your website up for tracking.

If you use JavaScript to navigate users from your website to your booking engine, this guide will help you complete your implementation of Discovery.

Before you begin

  • Your Flip.to code snippets should already be added to your website. See the guide to set up your website if you haven't completed this step.


Setting up cross-domain tracking

There are specific ways to set up tracking based on different JavaScript navigation approaches. Look for the approach that you use on your website and apply the appropriate code.

Approach 1: Delayed redirects

If you use the location.href property to redirect users (can also be location.assign, location.replace, window.open, $.post, or similar), and there is a delay or a user action is required before redirecting:

Add the following code before you redirect the user (using location.href as an example).

if ('function' == typeof window.fliptoDecorate) {
    bookingEngineUrl = fliptoDecorate(bookingEngineUrl);
}

location.href = bookingEngineUrl;

Approach 2: Form element redirects

If you use a formObject to redirect users (can also be document.form[0].submit(), document.querySelector(“nav.form”).submit, or similar):

Add the following code before you redirect the user (using formObject.submit() as an example).

if ('function' == typeof window.fliptoDecorate) {
   fliptoDecorate(formObject);
}

formObject.submit();

Approach 3: Immediate redirects

If you use location.href to redirect users (can also be location.assign, location.replace, window.open, $.post, or similar), and there is no delay and no user action is required before redirecting:

Replace your existing redirect with the following code. Adjust the code for your specific redirect property and preferred timing options (using location.href as an example).

(function(url, delay, max){
    var i = 0;
    var interval = window.setInterval(function() {
    if ('function' == typeof window.fliptoDecorate) {
        window.clearInterval(interval);
        window.location.href = window.fliptoDecorate(url);
    } else if (i++ >= max){
        window.clearInterval(interval);
        window.location.href = url;
    }
}, delay);
})(bookingEngineUrl, 100, 20);

The above shows waiting on fliptoDecorate up to 2 seconds, checking every 100ms.

Last updated