No backend? No problem.
Everything — the embed and the campaign tracking — runs client-side in JavaScript, since there's no server to process the company key or the tracking parameters.
Sitewide tracking + retrieval function
Add this to the <head> of every page of the site, before any widget or form. It must be in the <head>, not at the end of the page: the embeds below call it the moment they load.
<script>
(function(){
var KEYS = ['gclid','gbraid','wbraid','utm_source','utm_medium','utm_campaign','utm_term','utm_content','fbclid'];
// Stores a cookie if this page has any of them in the URL
KEYS.forEach(function(k){
var m = new RegExp('[?&]'+k+'=([^&#]*)').exec(window.location.href);
if(m && m[1]){
document.cookie = 'fb_' + k + '=' + m[1] + ';max-age=7776000;path=/;SameSite=Lax';
}
});
// Returns '&gclid=...&utm_source=...': this page's URL first, then the cookie
window.fbGetTrackingParams = function(){
var qs = '';
KEYS.forEach(function(k){
var m = new RegExp('[?&]'+k+'=([^&#]*)').exec(window.location.href);
var val = m ? m[1] : null;
if(!val){
var match = document.cookie.match(new RegExp('(^| )fb_' + k + '=([^;]+)'));
if(match) val = match[2];
}
if(val) qs += '&' + k + '=' + val;
});
return qs;
};
})();
</script>
If the site has a cookie banner (UK/EU), this cookie is advertising/measurement: load the script only after consent, or under the same rules as your Google tags.
Let the iframe resize itself
An iframe doesn't grow when its content grows — without telling it to, the form gets cut off the moment its content expands (opening the Options panel, for example). Both embeds below already include this, but the pattern is always the same three pieces, in this order:
- The resizer script — before the iframe
- The iframe itself, with a fixed
id - A small script that activates the resize — after the iframe, targeting that same
id
Use FareBookings' own copy of the script
app.farebookings.com/iframe-resizer/iframeResizer.min.js — not a third-party CDN. Ad blockers, corporate firewalls, and site-optimisation plugins sometimes block external CDNs but not the domain the widget already lives on.
Compact widget
<div id="fb-widget-container"></div>
<script src="https://app.farebookings.com/iframe-resizer/iframeResizer.min.js"></script>
<script>
(function(){
var container = document.getElementById('fb-widget-container');
var params = 'k=YOUR_COMPANY_KEY&lng=gb';
var tracking = window.fbGetTrackingParams ? window.fbGetTrackingParams() : '';
var iframe = document.createElement('iframe');
iframe.id = 'fb-booking-widget';
iframe.src = 'https://app.farebookings.com/booking-widget.php?' + params + tracking;
iframe.width = '100%';
iframe.height = '640';
iframe.frameBorder = '0';
iframe.scrolling = 'no';
iframe.style.border = 'none';
container.appendChild(iframe);
if (window.iFrameResize) {
iFrameResize({checkOrigin: false, heightCalculationMethod: 'lowestElement'}, '#fb-booking-widget');
}
})();
</script>
Full booking form
The most important fix on this page
If a compact widget elsewhere on the site (the homepage, say) submits and sends the visitor to this page, everything they already typed — origin, destination, date, passengers, plus any gclid/utm_* — arrives in this page's own URL. If this page doesn't read that and forward it into the iframe, all of it is lost and the form loads blank. This only applies when the widget sends visitors to a page of your own with the form embedded — if the widget links straight to app.farebookings.com instead, it builds that URL itself and none of this is needed.
The fix — read this page's own query string with window.location.search, forward it into the iframe, and then add any tracking saved in the cookie that isn't already in the URL:
<div id="fb-form-container"></div>
<script src="https://app.farebookings.com/iframe-resizer/iframeResizer.min.js"></script>
<script>
(function(){
var container = document.getElementById('fb-form-container');
var baseParams = 'k=YOUR_COMPANY_KEY&d=pp&lng=gb';
// 1. Forward EVERYTHING this page's own URL was given (the widget's data + gclid/utm)
var ownParams = window.location.search.replace(/^\?/, '');
var finalParams = baseParams + (ownParams ? '&' + ownParams : '');
// 2. Add any tracking saved in the cookie that isn't already in the URL
// (visitor landed on another page from an ad and reached this one via the menu)
var tracking = window.fbGetTrackingParams ? window.fbGetTrackingParams() : '';
tracking.split('&').forEach(function (pair) {
if (!pair) return;
var k = pair.split('=')[0];
if (!new RegExp('(^|&)' + k + '=').test(finalParams)) finalParams += '&' + pair;
});
var iframe = document.createElement('iframe');
iframe.id = 'fb-booking-form';
iframe.src = 'https://app.farebookings.com/step1sslv3.php?' + finalParams;
iframe.width = '100%';
iframe.style.border = 'none';
iframe.style.minHeight = '1400px';
iframe.scrolling = 'no';
container.appendChild(iframe);
if (window.iFrameResize) {
iFrameResize({checkOrigin: false, heightCalculationMethod: 'lowestElement'}, '#fb-booking-form');
}
})();
</script>
Replace YOUR_COMPANY_KEY with the real key from the Frontend tab of your panel, in both snippets above. The page's own URL always has priority; the cookie only fills in what is missing. That covers the visitor who lands on the homepage from an ad (/?gclid=…) and then reaches this page through the menu, where the URL carries nothing.
&dark=1 to params.&opts_open=1 to params.lng=gb to lng=es, lng=fr, etc.&layout=inline to params for the widget (not the full form). Needs ~1000px of width and stacks on its own under 900px — no separate markup for mobile. Set iframe.height to '200' instead of '640' when using this layout, or there's a visible gap under the bar for the first moment before iframeResizer measures it.Verifying tracking works
- Open an incognito window and visit any page other than the booking page with
?gclid=test123(for example/about/?gclid=test123). - Console (F12) → type
document.cookie→fb_gclid=test123should be there. - Navigate through the menu to the page with the widget or the full form (no parameters in the URL).
- Elements → find the FareBookings iframe → its
srcmust containgclid=test123. - If the site uses a page cache (Cloudflare, WP Rocket…), repeat step 1 with a different value (
test456) in the same incognito window: the iframe must showtest456, nevertest123from a cached page.
Building on a different platform?
There are dedicated guides for WordPress and plain PHP sites.