{"version":3,"file":"GA4Tracking.BChRSSif.mjs","names":[],"sources":["https:/framerusercontent.com/modules/XMmHs9tOGCHo7XTc001C/uCe8Dcxu3SQX8J9xSkOG/GA4Tracking.js"],"sourcesContent":["// GA4 Tracking Component for The Doctor LA\n// Injects Google Analytics 4 and tracks custom patient conversion events\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function GA4Tracking({measurementId=\"G-0NCRPCJ88B\",debug=false}){useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const log=(...args)=>{if(debug)console.log(\"[GA4Tracking]\",...args);};// --- 1. Inject gtag script ---\nconst existingScript=document.querySelector(`script[src*=\"googletagmanager.com/gtag/js?id=${measurementId}\"]`);if(!existingScript){const script=document.createElement(\"script\");script.async=true;script.src=`https://www.googletagmanager.com/gtag/js?id=${measurementId}`;document.head.appendChild(script);log(\"Injected gtag.js script for\",measurementId);}window.dataLayer=window.dataLayer||[];if(typeof window.gtag!==\"function\"){window.gtag=function(){window.dataLayer.push(arguments);};window.gtag(\"js\",new Date);window.gtag(\"config\",measurementId);log(\"Initialized gtag with config\",measurementId);}const gtag=window.gtag;const sendEvent=(eventName,params)=>{log(\"Event:\",eventName,params||\"\");gtag(\"event\",eventName,params);};// --- 2. Service page view ---\nif(window.location.pathname.startsWith(\"/services/\")){const serviceName=window.location.pathname.replace(\"/services/\",\"\").replace(/-/g,\" \");sendEvent(\"service_page_view\",{page_path:window.location.pathname,service_name:serviceName});}// --- 3. Click handler for all link-based events ---\nconst handleClick=e=>{const target=e.target;if(!target)return;// Walk up the DOM to find the nearest anchor or clickable element\nconst anchor=target.closest(\"a\");const href=anchor?.href||\"\";const textContent=target.textContent?.trim()||\"\";// book_click — link to book.thedoctor.me\nif(href.includes(\"book.thedoctor.me\")){sendEvent(\"book_click\",{link_url:href,link_text:textContent});}// imessage_click — Apple Business Chat\nif(href.includes(\"bcrw.apple.com\")){sendEvent(\"imessage_click\",{link_url:href});}// phone_call — tel: links\nif(href.startsWith(\"tel:\")){sendEvent(\"phone_call\",{phone_number:href.replace(\"tel:\",\"\")});}// sms_click — sms: links\nif(href.startsWith(\"sms:\")){sendEvent(\"sms_click\",{phone_number:href.replace(\"sms:\",\"\")});}// email_click — mailto: links\nif(href.startsWith(\"mailto:\")){sendEvent(\"email_click\",{email_address:href.replace(\"mailto:\",\"\")});}// provider_click — team member cards\nif(textContent===\"Read more\"||textContent===\"Book Visit\"||textContent===\"Read More\"||textContent===\"Book visit\"){// Try to find provider name from nearby content\nconst card=target.closest(\"[data-framer-name]\")||target.closest(\"div\");const cardText=card?.textContent||\"\";sendEvent(\"provider_click\",{link_text:textContent,card_context:cardText.substring(0,100)});}};// Use capture phase to intercept all clicks before they propagate\ndocument.addEventListener(\"click\",handleClick,true);log(\"Click listener attached (capture phase)\");// --- 4. Hash change for Talk To Us panel ---\nconst handleHashChange=()=>{if(window.location.hash===\"#talk\"){sendEvent(\"talk_to_us_open\",{page_path:window.location.pathname});}};window.addEventListener(\"hashchange\",handleHashChange);// Check on mount too\nif(window.location.hash===\"#talk\"){sendEvent(\"talk_to_us_open\",{page_path:window.location.pathname});}log(\"Hash change listener attached\");// --- 5. BookingDim2 transition detection ---\nconst observer=new MutationObserver(mutations=>{for(const mutation of mutations){if(mutation.type===\"childList\"){for(let i=0;i<mutation.addedNodes.length;i++){const node=mutation.addedNodes[i];if(node.nodeType===1){// Look for the BookingDim2 overlay element\n// It uses position:fixed or has booking-related attributes\nconst style=node.getAttribute?.(\"style\")||\"\";const text=node.textContent||\"\";if((style.includes(\"position: fixed\")||style.includes(\"position:fixed\"))&&(text.includes(\"book\")||text.includes(\"Book\")||text.includes(\"appointment\")||text.includes(\"Appointment\")||node.querySelector?.('a[href*=\"book.thedoctor.me\"]'))){sendEvent(\"booking_transition\",{page_path:window.location.pathname});break;}}}}}});observer.observe(document.body,{childList:true,subtree:true});log(\"MutationObserver attached for booking transition detection\");// --- Cleanup ---\nreturn()=>{document.removeEventListener(\"click\",handleClick,true);window.removeEventListener(\"hashchange\",handleHashChange);observer.disconnect();log(\"All listeners cleaned up\");};},[measurementId,debug]);// Render nothing visible\nreturn /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1,overflow:\"hidden\",position:\"absolute\",opacity:0,pointerEvents:\"none\"},\"aria-hidden\":\"true\"});}addPropertyControls(GA4Tracking,{measurementId:{type:ControlType.String,title:\"Measurement ID\",defaultValue:\"G-0NCRPCJ88B\",description:\"GA4 Measurement ID (starts with G-)\"},debug:{type:ControlType.Boolean,title:\"Debug Mode\",defaultValue:false,description:\"Log all tracked events to the browser console\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GA4Tracking\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GA4Tracking.map"],"mappings":"wLAKG,SAAwB,EAAY,CAAC,gBAAc,eAAe,QAAM,IAAO,CAmBlF,OAnBmF,MAAc,CAAC,GAAU,IAAS,QAAa,OAAO,SAAW,IAAY,OAAO,IAAM,GAAK,GAAG,IAAO,CAAI,GAAM,QAAQ,IAAI,gBAAgB,GAAG,EAAK,EAC3H,GAAG,CAA7F,SAAS,cAAc,gDAAgD,EAAc,IAAI,CAAoB,CAAC,IAAM,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,MAAM,GAAK,EAAO,IAAI,+CAA+C,IAAgB,SAAS,KAAK,YAAY,EAAO,CAAC,EAAI,8BAA8B,EAAc,CAAE,EAAO,UAAU,EAAO,WAAW,EAAE,CAAI,OAAO,EAAO,MAAO,aAAY,EAAO,KAAK,UAAU,CAAC,EAAO,UAAU,KAAK,UAAU,EAAG,EAAO,KAAK,KAAK,IAAI,KAAK,CAA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