diff --git a/apps/builder/src/features/blocks/integrations/googleAnalytics/components/GoogleAnalyticsSettings.tsx b/apps/builder/src/features/blocks/integrations/googleAnalytics/components/GoogleAnalyticsSettings.tsx index bc1e6f1664..5527805951 100644 --- a/apps/builder/src/features/blocks/integrations/googleAnalytics/components/GoogleAnalyticsSettings.tsx +++ b/apps/builder/src/features/blocks/integrations/googleAnalytics/components/GoogleAnalyticsSettings.tsx @@ -1,4 +1,4 @@ -import { TextInput } from '@/components/inputs' +import { NumberInput, TextInput } from '@/components/inputs' import { Accordion, AccordionButton, @@ -31,10 +31,10 @@ export const GoogleAnalyticsSettings = ({ const updateLabel = (label: string) => onOptionsChange({ ...options, label }) - const updateValue = (value?: string) => + const updateValue = (value: number | `{{${string}}}` | undefined) => onOptionsChange({ ...options, - value: value ? parseFloat(value) : undefined, + value, }) const updateSendTo = (sendTo?: string) => @@ -80,16 +80,17 @@ export const GoogleAnalyticsSettings = ({ placeholder="Example: Campaign Z" onChange={updateLabel} /> - diff --git a/packages/deprecated/bot-engine/src/lib/gtag.ts b/packages/deprecated/bot-engine/src/lib/gtag.ts index 0d9d13f62c..63c71f89bc 100644 --- a/packages/deprecated/bot-engine/src/lib/gtag.ts +++ b/packages/deprecated/bot-engine/src/lib/gtag.ts @@ -38,7 +38,7 @@ export const sendGaEvent = (options: GoogleAnalyticsOptions) => { gtag('event', options.action, { event_category: options.category, event_label: options.label, - value: options.value, + value: options.value as number, }) } diff --git a/packages/embeds/js/src/lib/gtag.ts b/packages/embeds/js/src/lib/gtag.ts index bbba19e930..8160454e6b 100644 --- a/packages/embeds/js/src/lib/gtag.ts +++ b/packages/embeds/js/src/lib/gtag.ts @@ -39,7 +39,7 @@ export const sendGaEvent = (options: GoogleAnalyticsOptions) => { gtag('event', options.action, { event_category: options.category, event_label: options.label, - value: options.value, + value: options.value as number, send_to: options.sendTo, }) } diff --git a/packages/schemas/features/blocks/integrations/googleAnalytics.ts b/packages/schemas/features/blocks/integrations/googleAnalytics.ts index 958a9797ab..3053628a0c 100644 --- a/packages/schemas/features/blocks/integrations/googleAnalytics.ts +++ b/packages/schemas/features/blocks/integrations/googleAnalytics.ts @@ -1,13 +1,14 @@ import { z } from 'zod' import { blockBaseSchema } from '../baseSchemas' import { IntegrationBlockType } from './enums' +import { variableStringSchema } from '../../utils' export const googleAnalyticsOptionsSchema = z.object({ trackingId: z.string().optional(), category: z.string().optional(), action: z.string().optional(), label: z.string().optional(), - value: z.number().optional(), + value: z.number().or(variableStringSchema).optional(), sendTo: z.string().optional(), })