Skip to content

Scheduling infrastructure for absolutely everyone.

Make trackingId begin with GTM- always (#8937)

Hariom Balharad5746ed277b6
diff --git a/packages/app-store/gtm/config.json b/packages/app-store/gtm/config.json
index c691e6f7ef0..b2faf7243db 100644
--- a/packages/app-store/gtm/config.json
+++ b/packages/app-store/gtm/config.json
@@ -14,7 +14,7 @@
"tag": {
"scripts": [
{
- "content": "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-{TRACKING_ID}');"
+ "content": "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','{TRACKING_ID}');"
}
]
}
diff --git a/packages/app-store/gtm/zod.ts b/packages/app-store/gtm/zod.ts
index 6f45d901ccf..297950930cf 100644
--- a/packages/app-store/gtm/zod.ts
+++ b/packages/app-store/gtm/zod.ts
@@ -4,7 +4,12 @@ import { eventTypeAppCardZod } from "@calcom/app-store/eventTypeAppCardZod";
export const appDataSchema = eventTypeAppCardZod.merge(
z.object({
- trackingId: z.string(),
+ trackingId: z.string().transform((val) => {
+ let trackingId = val.trim();
+ // Ensure that trackingId is transformed if needed to begin with "GTM-" always
+ trackingId = !trackingId.startsWith("GTM-") ? `GTM-${trackingId}` : trackingId;
+ return trackingId;
+ }),
})
);