A copy-paste iframe, with real tracking.
No plugin needed — just an iframe embed and one small helper function, so Google Ads and Meta can still attribute bookings correctly.
Sitewide tracking
Add this to the <head> of every page, in the shared header template, before any widget or form. This step is required: without it there is no cookie, and a visitor who reaches the booking page through the menu loses their gclid.
<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.
Helper function
Add this once, in a shared include:
<?php
// Only reads THIS page's URL. Never the cookie: page caches (Cloudflare, WP Rocket,
// LiteSpeed...) would store one visitor's gclid and serve it to everyone.
// Tracking saved in the cookie is added in the browser (see "Complete from the cookie").
function fb_tracking_query() {
$keys = ['gclid','gbraid','wbraid','utm_source','utm_medium','utm_campaign','utm_term','utm_content','fbclid'];
$qs = '';
foreach ($keys as $k) {
if (!empty($_GET[$k]) && is_string($_GET[$k])) {
$qs .= '&' . $k . '=' . rawurlencode($_GET[$k]);
}
}
return $qs;
}
?>
Don't read the tracking cookie in PHP
Page caches (Cloudflare, WP Rocket, LiteSpeed…) would store one visitor's gclid in the HTML and serve it to everyone. This function only reads the page's own URL, which is part of the cache key; the cookie is added in the browser in step 06.
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
<script src="https://app.farebookings.com/iframe-resizer/iframeResizer.min.js"></script>
<iframe
id="fb-booking-widget"
src="https://app.farebookings.com/booking-widget.php?k=YOUR_COMPANY_KEY&lng=gb<?php echo fb_tracking_query(); ?>"
width="100%" height="640" frameborder="0" scrolling="no" style="border:none">
</iframe>
<script>
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 — forward this page's entire query string into the iframe, without listing each parameter by hand:
<script src="https://app.farebookings.com/iframe-resizer/iframeResizer.min.js"></script>
<?php
// Forward everything this page's own URL was given — this is what
// carries the widget's data through when it redirects here.
$ownParams = $_SERVER['QUERY_STRING'] ?? '';
?>
<iframe
id="fb-booking-form"
src="https://app.farebookings.com/step1sslv3.php?k=YOUR_COMPANY_KEY&d=pp&lng=gb<?php echo $ownParams ? '&' . htmlspecialchars($ownParams, ENT_QUOTES, 'UTF-8') : ''; ?>"
width="100%" scrolling="no" style="border:none;min-height:1400px">
</iframe>
<script>
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. Forwarding $_SERVER['QUERY_STRING'] carries through anything the widget sent — including gclid/utm_*. Tracking saved in the cookie is added by step 06.
Complete from the cookie
Add this before </body> on every page, after the iframes (shared footer). It runs in the browser and adds the tracking saved in the cookie that is missing from the iframe's URL, so it is safe with any page cache.
<script>
// Adds tracking saved in the fb_* cookies that isn't already in the src of the
// FareBookings iframes. Only reloads an iframe if something was actually missing.
(function () {
if (!window.fbGetTrackingParams) return;
var extra = window.fbGetTrackingParams(); // '&gclid=...&utm_source=...'
if (!extra) return;
var frames = document.querySelectorAll('iframe[src*="app.farebookings.com/booking-widget.php"], iframe[src*="app.farebookings.com/step1sslv3.php"]');
Array.prototype.forEach.call(frames, function (el) {
var src = el.getAttribute('src');
var add = extra.split('&').filter(function (pair) {
if (!pair) return false;
var k = pair.split('=')[0];
return !new RegExp('[?&]' + k + '=').test(src);
});
if (add.length) el.setAttribute('src', src + (src.indexOf('?') === -1 ? '?' : '&') + add.join('&'));
});
})();
</script>
&dark=1 to the iframe URL.&opts_open=1.lng=gb to lng=es, lng=fr, etc.&layout=inline to the widget iframe URL (widget only, not the full form). Needs ~1000px of width and stacks on its own under 900px — no separate markup for mobile. Set the iframe's starting 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 sites with no backend at all.