diff --git a/src/app/actions.ts b/src/app/actions.ts index d636cec..97cd728 100644 --- a/src/app/actions.ts +++ b/src/app/actions.ts @@ -302,10 +302,18 @@ export async function extractMetaData(url: string, keyword?: string) { let hotjarMatch = htmlContent.match(/hjid:(\d+)/); if (hotjarMatch) uniqueTrackers.set("Hotjar", hotjarMatch[1]); - let hubspotMatch = htmlContent.match( - /js(?:-[a-zA-Z0-9]+)?\.hs-scripts\.com\/(\d+)\.js/ - ); - if (hubspotMatch) uniqueTrackers.set("HubSpot", hubspotMatch[2] || hubspotMatch[1]); + + // HubSpot (scan script tags) + $('script[src]').each((i, el) => { + const src = $(el).attr('src'); + if (src && src.includes('.hs-scripts.com/')) { + const match = src.match(/(\d+)\.js$/); + if (match && match[1]) { + uniqueTrackers.set("HubSpot", match[1]); + return false; // Stop iterating once found + } + } + }); const detectedTracking: TrackingTool[] = Array.from( uniqueTrackers,