> For the complete documentation index, see [llms.txt](https://docs.flip.to/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flip.to/docs/integrations/websites/cross-domain-tracking.md).

# 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.

{% hint style="warning" %}
**Before you begin**: your Flip.to code snippets should already be added to your website. See the guide to [set up your website](/docs/integrations/websites/set-up-your-website.md) if you haven't completed this step.
{% endhint %}

***

## 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).

```javascript
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).

```javascript
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).

```javascript
(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.*

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flip.to/docs/integrations/websites/cross-domain-tracking.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
