diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index cccd30f..2368625 100755 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -121,7 +121,7 @@ import LoadingPage from "../pages/LoadingPage"; import { EProductKeys, productUrls } from "@/data/products"; import SinglePaymentPage from "../pages/SinglePaymentPage"; import ABDesignV1Routes from "@/routerComponents/ABDesign/v1"; -import metricService from "@/services/metric/metricService"; +import metricService, {EGoals} from "@/services/metric/metricService"; const isProduction = import.meta.env.MODE === "production"; @@ -164,6 +164,11 @@ function App(): JSX.Element { const birthPlace = user?.profile?.birthplace || birthPlaceFromStore; useEffect(() => { + if (location.pathname.includes("v1/trial-choice")) { + metricService.reachGoal(EGoals.AURA_TRIAL_CHOICE_PAGE_VISIT, true) + } else if (location.pathname.includes("v1/trial-payment")) { + metricService.reachGoal(EGoals.AURA_TRIAL_PAYMENT_PAGE_VISIT, true) + } metricService.hit() }, [location]); diff --git a/src/services/metric/metricService.ts b/src/services/metric/metricService.ts index ce8174e..729bb7a 100644 --- a/src/services/metric/metricService.ts +++ b/src/services/metric/metricService.ts @@ -10,7 +10,9 @@ export enum EGoals { ROSE_VIDEO_PLAY_USER_STOP = "RoseVideoPlayUserStop", ROSE_VIDEO_PLAY_USER_PLAY = "RoseVideoPlayUserPlay", AURA_PAYMENT_METHODS_OPENED = "AuraPaymentMethodsOpened", - AURA_SELECT_TRIAL = "AuraSelectTrial" + AURA_SELECT_TRIAL = "AuraSelectTrial", + AURA_TRIAL_CHOICE_PAGE_VISIT = "AuraTrialChoicePageVisit", + AURA_TRIAL_PAYMENT_PAGE_VISIT = "AuraTrialPaymentPageVisit" } interface IUserParams { @@ -47,14 +49,19 @@ const userParams = (parameters: Partial) => { window.klaviyo.push(['identify', parameters]); } -const reachGoal = (goal: EGoals) => { - if (!checkIsAvailableYandexMetric()) return; +const reachGoal = (goal: EGoals, onlyKlaviyo = false) => { + if (onlyKlaviyo) { + if (!window.klaviyo) return console.error("Klaviyo.Metric not found"); + window.klaviyo.push(['track', goal]); + } else { + if (!checkIsAvailableYandexMetric()) return; - window.ym(metricCounterNumber, "reachGoal", goal) - console.log("goal: ", goal); + window.ym(metricCounterNumber, "reachGoal", goal) + console.log("goal: ", goal); - if (!window.klaviyo) return console.error("Klaviyo.Metric not found"); - window.klaviyo.push(['track', goal]); + if (!window.klaviyo) return console.error("Klaviyo.Metric not found"); + window.klaviyo.push(['track', goal]); + } } type THitOptions = {