метрика полей ФК

This commit is contained in:
Nastya 2024-05-12 21:41:13 +03:00
parent 282ff1beeb
commit 389d977b3c
4 changed files with 43 additions and 28 deletions

@ -69,18 +69,18 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
currentQuestion.type === "result" currentQuestion.type === "result"
? currentQuestion ? currentQuestion
: questions.find((question): question is QuizQuestionResult => { : questions.find((question): question is QuizQuestionResult => {
if (settings?.cfg.haveRoot) { if (settings?.cfg.haveRoot) {
return ( return (
question.type === "result" && question.type === "result" &&
question.content.rule.parentId === currentQuestion.content.id question.content.rule.parentId === currentQuestion.content.id
); );
} else { } else {
return ( return (
question.type === "result" && question.type === "result" &&
question.content.rule.parentId === "line" question.content.rule.parentId === "line"
); );
} }
}); });
if (!resultQuestion) throw new Error("Result question not found"); if (!resultQuestion) throw new Error("Result question not found");
@ -153,6 +153,27 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
vkMetrics.contactsFormFilled(); vkMetrics.contactsFormFilled();
yandexMetrics.contactsFormFilled(); yandexMetrics.contactsFormFilled();
//Оповещаем какие поля были заполнены
if (name.length !== 0) {
vkMetrics.contactsFormField("name");
yandexMetrics.contactsFormField("name");
}
if (email.length !== 0) {
vkMetrics.contactsFormField("email");
yandexMetrics.contactsFormField("email");
}
if (phone.length !== 0) {
vkMetrics.contactsFormField("phone");
yandexMetrics.contactsFormField("phone");
}
if (text.length !== 0) {
vkMetrics.contactsFormField("text");
yandexMetrics.contactsFormField("text");
}
if (adress.length !== 0) {
vkMetrics.contactsFormField("address");
yandexMetrics.contactsFormField("address");
}
} catch (e) { } catch (e) {
enqueueSnackbar("повторите попытку позже"); enqueueSnackbar("повторите попытку позже");
} }
@ -190,9 +211,8 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
settings.cfg.design && !isMobile settings.cfg.design && !isMobile
? quizThemes[settings.cfg.theme].isLight ? quizThemes[settings.cfg.theme].isLight
? `url(${DESIGN_LIST[settings.cfg.theme]})` ? `url(${DESIGN_LIST[settings.cfg.theme]})`
: `linear-gradient(90deg, #272626, transparent), url(${ : `linear-gradient(90deg, #272626, transparent), url(${DESIGN_LIST[settings.cfg.theme]
DESIGN_LIST[settings.cfg.theme] })`
})`
: null, : null,
}} }}
> >
@ -230,8 +250,8 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
p: isMobile p: isMobile
? "0 20px" ? "0 20px"
: isTablet : isTablet
? "0px 40px 30px 60px" ? "0px 40px 30px 60px"
: "125px 60px 30px 60px", : "125px 60px 30px 60px",
}} }}
> >
<Box <Box
@ -315,9 +335,8 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
<Box <Box
component={Link} component={Link}
target={"_blank"} target={"_blank"}
href={`https://${ href={`https://${window.location.hostname.includes("s") ? "s" : ""
window.location.hostname.includes("s") ? "s" : "" }quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
sx={{ sx={{
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",

@ -36,8 +36,6 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
useEffect(() => { useEffect(() => {
vkMetrics.resultIdShown(resultQuestion.id); vkMetrics.resultIdShown(resultQuestion.id);
yandexMetrics.resultIdShown(resultQuestion.id); yandexMetrics.resultIdShown(resultQuestion.id);
vkMetrics.resultShown();
yandexMetrics.resultShown();
}, []); }, []);
return ( return (

@ -31,9 +31,6 @@ export const useVkMetricsGoals = (vkId: number | undefined) => {
// Посетитель увидел определенный результат (id - айдишник вопроса с типом result) // Посетитель увидел определенный результат (id - айдишник вопроса с типом result)
resultIdShown: (resultId: string) => resultIdShown: (resultId: string) =>
sendMetrics(vkId, `penaquiz-result-${resultId}`), sendMetrics(vkId, `penaquiz-result-${resultId}`),
// Посетитель увидел результат
resultShown: () =>
sendMetrics(vkId, `penaquiz-finish`),
// Посетитель нажал на ссылку в результате // Посетитель нажал на ссылку в результате
resultLink: () => resultLink: () =>
sendMetrics(vkId, `penaquiz-resultlink`), sendMetrics(vkId, `penaquiz-resultlink`),
@ -41,6 +38,8 @@ export const useVkMetricsGoals = (vkId: number | undefined) => {
contactsFormOpened: () => sendMetrics(vkId, "penaquiz-form"), contactsFormOpened: () => sendMetrics(vkId, "penaquiz-form"),
// Посетитель заполнил форму контактов // Посетитель заполнил форму контактов
contactsFormFilled: () => sendMetrics(vkId, "penaquiz-contacts"), contactsFormFilled: () => sendMetrics(vkId, "penaquiz-contacts"),
// Посетитель заполнил поле формы контактов
contactsFormField: (field: string) => sendMetrics(vkId, `penaquiz-formfield-${field}`),
// Посетитель отправил заявку с мессенджером // Посетитель отправил заявку с мессенджером
messengerRequestSended: (messenger: MetricsMessengers) => messengerRequestSended: (messenger: MetricsMessengers) =>
sendMetrics(vkId, `penaquiz-messengers-${messenger}`), sendMetrics(vkId, `penaquiz-messengers-${messenger}`),

@ -23,9 +23,6 @@ export const useYandexMetricsGoals = (id: number | undefined) => {
// Посетитель увидел определенный результат (id - айдишник вопроса с типом result) // Посетитель увидел определенный результат (id - айдишник вопроса с типом result)
resultIdShown: (resultId: string) => resultIdShown: (resultId: string) =>
sendMetrics(id, `penaquiz-result-${resultId}`), sendMetrics(id, `penaquiz-result-${resultId}`),
// Посетитель увидел результат
resultShown: () =>
sendMetrics(id, `penaquiz-finish`),
// Посетитель нажал на ссылку в результате // Посетитель нажал на ссылку в результате
resultLink: () => resultLink: () =>
sendMetrics(id, `penaquiz-resultlink`), sendMetrics(id, `penaquiz-resultlink`),
@ -33,6 +30,8 @@ export const useYandexMetricsGoals = (id: number | undefined) => {
contactsFormOpened: () => sendMetrics(id, "penaquiz-form"), contactsFormOpened: () => sendMetrics(id, "penaquiz-form"),
// Посетитель заполнил форму контактов // Посетитель заполнил форму контактов
contactsFormFilled: () => sendMetrics(id, "penaquiz-contacts"), contactsFormFilled: () => sendMetrics(id, "penaquiz-contacts"),
// Посетитель заполнил поле формы контактов
contactsFormField: (field: string) => sendMetrics(id, `penaquiz-formfield-${field}`),
// Посетитель отправил заявку с мессенджером // Посетитель отправил заявку с мессенджером
messengerRequestSended: (messenger: MetricsMessengers) => messengerRequestSended: (messenger: MetricsMessengers) =>
sendMetrics(id, `penaquiz-messengers-${messenger}`), sendMetrics(id, `penaquiz-messengers-${messenger}`),