[dyad] Improved tracker ID detection with more robust patterns - wrote 1 file(s)
This commit is contained in:
@@ -323,9 +323,12 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
htmlContent.includes("connect.facebook.net") ||
|
||||
htmlContent.includes("fbq('init'")
|
||||
) {
|
||||
const fbIdMatch = htmlContent.match(
|
||||
let fbIdMatch = htmlContent.match(
|
||||
/fbq\(\s*['"]init['"]\s*,\s*['"](\d+)['"]\s*\)/
|
||||
);
|
||||
if (!fbIdMatch) {
|
||||
fbIdMatch = htmlContent.match(/facebook\.com\/tr\?.*?id=(\d+)/);
|
||||
}
|
||||
addTracker("Facebook Pixel", fbIdMatch ? fbIdMatch[1] : null);
|
||||
}
|
||||
|
||||
@@ -340,7 +343,12 @@ export async function extractMetaData(url: string, keyword?: string) {
|
||||
|
||||
// HubSpot
|
||||
if (htmlContent.includes("js.hs-scripts.com")) {
|
||||
const hsIdMatch = htmlContent.match(/js\.hs-scripts\.com\/(\d+)\.js/);
|
||||
let hsIdMatch = htmlContent.match(/js\.hs-scripts\.com\/(\d+)\.js/);
|
||||
if (!hsIdMatch) {
|
||||
hsIdMatch = htmlContent.match(
|
||||
/_hsq\.push\(\s*\[\s*['"]setAccountId['"]\s*,\s*['"](\d+)['"]\s*\]\s*\)/
|
||||
);
|
||||
}
|
||||
addTracker("HubSpot", hsIdMatch ? hsIdMatch[1] : null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user