Introduction On 6 August 2025, the High Court of Australia delivered its long-awaited judgment in Helensburgh Coal Pty Ltd v Bartley. The case has become a landmark in shaping how Helensburgh Coal redundancy redeployment is understood under the Fair Work Act 2009 (Cth). The Court clarified one of the most contested aspects of Australia’s unfair …
- End", entire site, priority AFTER 8417.
*
* What it does:
* 1. On load, reads gclid + utm_* from the URL and stores them in a
* first-party cookie for 90 days (only overwrites gclid when a new one
* is present, so a later organic visit does not wipe the paid click).
* 2. Appends those params to every calendly.com link and to any inline
* Calendly embed, so a completed booking carries them into Calendly and
* onward to the RedRain integration.
*/
(function () {
'use strict';
var COOKIE = 'jm_attr';
var MAXAGE = 60 * 60 * 24 * 90; // 90 days
var UTM_KEYS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'];
function readCookie(name) {
var m = document.cookie.match('(?:^|; )' + name + '=([^;]*)');
return m ? decodeURIComponent(m[1]) : '';
}
function writeCookie(name, val) {
document.cookie = name + '=' + encodeURIComponent(val) +
'; path=/; max-age=' + MAXAGE + '; SameSite=Lax; Secure';
}
// ---- 1. capture from URL, merge with stored ----
function capture() {
var url = new URLSearchParams(window.location.search);
var stored = {};
try { stored = JSON.parse(readCookie(COOKIE) || '{}'); } catch (e) { stored = {}; }
var incomingGclid = url.get('gclid');
if (incomingGclid) { stored.gclid = incomingGclid; } // only overwrite on a fresh click
UTM_KEYS.forEach(function (k) {
var v = url.get(k);
if (v) { stored[k] = v; }
});
// if a gclid arrived but no utm_source, tag the source so RedRain is not blank
if (incomingGclid && !stored.utm_source) { stored.utm_source = 'google'; stored.utm_medium = 'cpc'; }
if (Object.keys(stored).length) { writeCookie(COOKIE, JSON.stringify(stored)); }
return stored;
}
var attr = capture();
if (!attr || (!attr.gclid && !attr.utm_source)) { return; } // nothing to forward
// ---- 2. build a query string for Calendly ----
function calendlyParams() {
var p = new URLSearchParams();
UTM_KEYS.forEach(function (k) { if (attr[k]) { p.set(k, attr[k]); } });
// carry the raw gclid too. utm_content is the safe carrier RedRain can map
// if its Calendly field mapping does not expose a native gclid slot.
if (attr.gclid) {
p.set('gclid', attr.gclid);
if (!p.get('utm_content')) { p.set('utm_content', 'gclid:' + attr.gclid); }
}
return p.toString();
}
function withParams(href) {
if (!href || href.indexOf('calendly.com') === -1) { return href; }
var qs = calendlyParams();
if (!qs) { return href; }
// don't double-append
if (href.indexOf('utm_source=') !== -1 || href.indexOf('gclid=') !== -1) { return href; }
return href + (href.indexOf('?') === -1 ? '?' : '&') + qs;
}
// ---- 3a. rewrite anchor links (covers the popup/booking click path) ----
function rewriteLinks() {
var links = document.querySelectorAll('a[href*="calendly.com"]');
for (var i = 0; i < links.length; i++) {
var a = links[i];
if (a.getAttribute('data-jm-attr') === '1') { continue; }
a.setAttribute('href', withParams(a.getAttribute('href')));
a.setAttribute('data-jm-attr', '1');
}
}
// ---- 3b. rewrite inline embeds. Must run before Calendly widget.js reads
// data-url; if the widget already initialised, re-point and let it
// re-read on next interaction. Most bookings go via the link path. ----
function rewriteEmbeds() {
var w = document.querySelectorAll('.calendly-inline-widget[data-url]');
for (var i = 0; i < w.length; i++) {
var el = w[i];
if (el.getAttribute('data-jm-attr') === '1') { continue; }
el.setAttribute('data-url', withParams(el.getAttribute('data-url')));
el.setAttribute('data-jm-attr', '1');
}
}
function run() { rewriteLinks(); rewriteEmbeds(); }
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', run);
} else {
run();
}
// catch links injected later (Elementor popups, lazy content)
if (window.MutationObserver) {
var mo = new MutationObserver(function () { rewriteLinks(); });
mo.observe(document.documentElement, { childList: true, subtree: true });
}
})();