{"version":3,"file":"BookingTracking.LMnoHyfx.mjs","names":[],"sources":["https:/framerusercontent.com/modules/yJmK2qHoB6z3uZvsjPI6/p7pY96Wt0ISdM6sFDTiJ/BookingTracking.js"],"sourcesContent":["/*\n * Aquasense – tracking for booking buttons (book.birdy.life)\n *\n * Request (Frank, 30 Sep 2026): \"Make code for the buttons that passes the ad\n * codes (fbclid, UTMs) on to the booking link and makes the clicks measurable.\"\n *\n * What these overrides do when attached to a button that links to book.birdy.life:\n * 1. On page load: remember the ad parameters from the page URL\n *    (utm_*, fbclid, gclid) in sessionStorage, so they survive a scroll\n *    or anchor jump on the page.\n * 2. On click: append those parameters to the booking link, so the Meta\n *    pixel and GA4 on book.birdy.life still know which ad the visitor came from.\n * 3. On click: push a \"cta_click\" event to the dataLayer (for Google Tag Manager)\n *    and, if the Meta pixel is loaded on this site, send a \"CtaClick\" custom event.\n *\n * One override per button position, so reports show which button works:\n *   withBookingHero   – buttons in the hero\n *   withBookingIntro  – buttons in the intro block\n *   withBookingEnd    – buttons in the closing block (\"Klaar met scheren?\")\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";const AD_KEYS=[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_content\",\"utm_term\",\"fbclid\",\"gclid\"];const STORAGE_KEY=\"aquasense_ad_params\";const BOOKING_HOST=\"book.birdy.life\";// Read ad parameters from the current URL, merge with what was stored earlier, store again.\nfunction collectAdParams(){if(typeof window===\"undefined\")return{};let stored={};try{stored=JSON.parse(window.sessionStorage.getItem(STORAGE_KEY)||\"{}\");}catch(e){stored={};}const query=new URLSearchParams(window.location.search);let changed=false;AD_KEYS.forEach(key=>{const value=query.get(key);if(value){stored[key]=value;changed=true;}});if(changed){try{window.sessionStorage.setItem(STORAGE_KEY,JSON.stringify(stored));}catch(e){// storage blocked (private mode): the URL parameters still work for this click\n}}return stored;}// Add the ad parameters to the booking link, without overwriting ones already on it.\nfunction withAdParams(href,params){try{const url=new URL(href,window.location.href);Object.keys(params).forEach(key=>{if(!url.searchParams.has(key))url.searchParams.set(key,params[key]);});return url.toString();}catch(e){return href;}}function trackAndGo(Component,position){return function BookingTrackedButton(props){useEffect(()=>{collectAdParams();},[]);const handleClick=event=>{if(typeof props.onClick===\"function\")props.onClick(event);if(typeof window===\"undefined\")return;const element=event.currentTarget;const anchor=element.closest(\"a\")||element.querySelector(\"a\");if(!anchor||!anchor.href||anchor.href.indexOf(BOOKING_HOST)===-1)return;const url=withAdParams(anchor.href,collectAdParams());let product=\"\";try{product=new URL(url).pathname.split(\"/\").filter(Boolean).pop()||\"\";}catch(e){product=\"\";}const w=window;w.dataLayer=w.dataLayer||[];w.dataLayer.push({event:\"cta_click\",cta_position:position,cta_product:product,cta_text:(element.innerText||\"\").trim(),cta_url:url});if(typeof w.fbq===\"function\"){w.fbq(\"trackCustom\",\"CtaClick\",{cta_position:position,cta_product:product});}// Cmd/Ctrl/Shift/middle click: let the browser open a new tab, with the parameters added.\nif(event.metaKey||event.ctrlKey||event.shiftKey||event.button===1){anchor.href=url;return;}// Normal click: give the tags 150 ms to send, then go to the booking page.\nevent.preventDefault();window.setTimeout(()=>{window.location.href=url;},150);};return /*#__PURE__*/_jsx(Component,{...props,onClick:handleClick});};}export function withBookingHero(Component){return trackAndGo(Component,\"hero\");}export function withBookingIntro(Component){return trackAndGo(Component,\"intro\");}export function withBookingEnd(Component){return trackAndGo(Component,\"slot\");}\nexport const __FramerMetadata__ = {\"exports\":{\"withBookingIntro\":{\"type\":\"reactHoc\",\"name\":\"withBookingIntro\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBookingEnd\":{\"type\":\"reactHoc\",\"name\":\"withBookingEnd\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBookingHero\":{\"type\":\"reactHoc\",\"name\":\"withBookingHero\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BookingTracking.map"],"mappings":"gIAoBA,SAAS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