From 83c19903abaddfe9a84733f251f0c8f1146232ab Mon Sep 17 00:00:00 2001 From: parsa aghaei Date: Wed, 2 Sep 2026 13:28:06 +0330 Subject: [PATCH] feat(seo): add smart script extraction and preview for GTM, GA4, Clarity, and GSC --- .../admin-panel/src/pages/SeoSettingsPage.tsx | 102 ++++++++++++++---- 1 file changed, 83 insertions(+), 19 deletions(-) diff --git a/frontend/admin-panel/src/pages/SeoSettingsPage.tsx b/frontend/admin-panel/src/pages/SeoSettingsPage.tsx index cf98671..6bdf510 100644 --- a/frontend/admin-panel/src/pages/SeoSettingsPage.tsx +++ b/frontend/admin-panel/src/pages/SeoSettingsPage.tsx @@ -359,10 +359,10 @@ export default function SeoSettingsPage() { value={seo.googleSiteVerification || ''} onChange={(e) => { let val = e.target.value.trim(); - // Auto-extract content if user pasted full - const match = val.match(/content=["']([^"']+)["']/); + const match = val.match(/content=["']([^"']+)["']/i); if (match && match[1]) { val = match[1]; + toast.success('کد تأییدیه گوگل از متاتگ با موفقیت استخراج شد'); } setSeo({ ...seo, googleSiteVerification: val }); }} @@ -377,7 +377,7 @@ export default function SeoSettingsPage() { {seo.googleSiteVerification && (
- متاتگ تزریق شده در سایت: + متاتگ تزریق شده در <head> سایت: <meta name="google-site-verification" content="{seo.googleSiteVerification}" /> @@ -412,7 +412,7 @@ export default function SeoSettingsPage() {
@@ -505,7 +536,7 @@ export default function SeoSettingsPage() { {seo.googleTagManagerId && seo.enableGoogleTagManager !== false ? ( - کانتینر GTM در Head و Noscript لود می‌شود + اسکریپت GTM در <head> و تگ noscript در <body> فعال است ) : ( @@ -513,6 +544,18 @@ export default function SeoSettingsPage() { )}
+ + {seo.googleTagManagerId && ( +
+ تزریق خودکار در <head> و ابتدای <body>: + + Head: https://www.googletagmanager.com/gtm.js?id={seo.googleTagManagerId} + + + Body: <noscript><iframe src="...id={seo.googleTagManagerId}"></noscript> + +
+ )} {/* Microsoft Clarity Card */} @@ -543,7 +586,7 @@ export default function SeoSettingsPage() {
setSeo({ ...seo, clarityProjectId: e.target.value.trim() })} - placeholder="مثال: abcde12345" - className="w-full px-4 py-2.5 rounded-xl border border-gray-200 focus:border-orange-500 outline-none text-xs font-mono" + onChange={(e) => { + let val = e.target.value.trim(); + // Auto-extract Clarity ID if user pasted full script snippet or URL + const scriptMatch = val.match(/["']clarity["']\s*,\s*["']script["']\s*,\s*["']([a-zA-Z0-9]+)["']/i); + const urlMatch = val.match(/clarity\.ms\/tag\/([a-zA-Z0-9]+)/i); + if (scriptMatch && scriptMatch[1]) { + val = scriptMatch[1]; + toast.success(`شناسه کلاریتی ${val} با موفقیت استخراج شد`); + } else if (urlMatch && urlMatch[1]) { + val = urlMatch[1]; + toast.success(`شناسه کلاریتی ${val} با موفقیت استخراج شد`); + } + setSeo({ ...seo, clarityProjectId: val }); + }} + placeholder="مثال: ybybyi7z4p یا کل کد " + className="w-full px-4 py-2.5 rounded-xl border border-gray-200 focus:border-orange-500 outline-none text-xs font-mono font-bold" dir="ltr" />

- ابزار کاملاً رایگان مایکروسافت برای مشاهده رفتار خرید کاربران در صفحه محصول و چک‌اوت. + می‌توانید شناسه پروژه یا کل کد اسکریپت Clarity را پیست کنید (خودکار استخراج می‌شود).

- + {seo.clarityProjectId && ( +
+ اسکریپت فعال در سایت: + + https://www.clarity.ms/tag/{seo.clarityProjectId} + +
+ )} +