Merge branch 'AW-106-klaviyo-metric' into 'develop'

AW-106-klaviyo-metric

See merge request witapp/aura-webapp!232
This commit is contained in:
Daniil Chemerkin 2024-07-09 17:35:27 +00:00
commit b954612a6e
2 changed files with 20 additions and 8 deletions

View File

@ -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]);

View File

@ -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<IUserParams>) => {
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 = {