AW-106-klaviyo-metric
new using klaviyo
This commit is contained in:
parent
89b0939b83
commit
b1882b5e68
49
index.html
49
index.html
@ -58,6 +58,55 @@
|
|||||||
script.async = "";
|
script.async = "";
|
||||||
document.head.appendChild(script);
|
document.head.appendChild(script);
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
!(function () {
|
||||||
|
if (!window.klaviyo) {
|
||||||
|
window._klOnsite = window._klOnsite || [];
|
||||||
|
try {
|
||||||
|
window.klaviyo = new Proxy(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
get: function (n, i) {
|
||||||
|
return "push" === i
|
||||||
|
? function () {
|
||||||
|
var n;
|
||||||
|
(n = window._klOnsite).push.apply(n, arguments);
|
||||||
|
}
|
||||||
|
: function () {
|
||||||
|
for (
|
||||||
|
var n = arguments.length, o = new Array(n), w = 0;
|
||||||
|
w < n;
|
||||||
|
w++
|
||||||
|
)
|
||||||
|
o[w] = arguments[w];
|
||||||
|
var t =
|
||||||
|
"function" == typeof o[o.length - 1]
|
||||||
|
? o.pop()
|
||||||
|
: void 0,
|
||||||
|
e = new Promise(function (n) {
|
||||||
|
window._klOnsite.push(
|
||||||
|
[i].concat(o, [
|
||||||
|
function (i) {
|
||||||
|
t && t(i), n(i);
|
||||||
|
},
|
||||||
|
])
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return e;
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (n) {
|
||||||
|
(window.klaviyo = window.klaviyo || []),
|
||||||
|
(window.klaviyo.push = function () {
|
||||||
|
var n;
|
||||||
|
(n = window._klOnsite).push.apply(n, arguments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
<!-- Klaviyo Metric -->
|
<!-- Klaviyo Metric -->
|
||||||
<!-- Yandex.Metrika counter -->
|
<!-- Yandex.Metrika counter -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|||||||
@ -35,16 +35,16 @@ const setUserID = (userId: string) => {
|
|||||||
if (!checkIsAvailableYandexMetric()) return;
|
if (!checkIsAvailableYandexMetric()) return;
|
||||||
window.ym(metricCounterNumber, "setUserID", userId)
|
window.ym(metricCounterNumber, "setUserID", userId)
|
||||||
|
|
||||||
if (!window._learnq) return console.error("Klaviyo.Metric not found");
|
if (!window.klaviyo) return console.error("Klaviyo.Metric not found");
|
||||||
window._learnq.push(['identify', userId]);
|
window.klaviyo.push(['identify', userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userParams = (parameters: Partial<IUserParams>) => {
|
const userParams = (parameters: Partial<IUserParams>) => {
|
||||||
if (!checkIsAvailableYandexMetric()) return;
|
if (!checkIsAvailableYandexMetric()) return;
|
||||||
window.ym(metricCounterNumber, "userParams", parameters)
|
window.ym(metricCounterNumber, "userParams", parameters)
|
||||||
|
|
||||||
if (!window._learnq) return console.error("Klaviyo.Metric not found");
|
if (!window.klaviyo) return console.error("Klaviyo.Metric not found");
|
||||||
window._learnq.push(['identify', parameters]);
|
window.klaviyo.push(['identify', parameters]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const reachGoal = (goal: EGoals) => {
|
const reachGoal = (goal: EGoals) => {
|
||||||
@ -53,8 +53,8 @@ const reachGoal = (goal: EGoals) => {
|
|||||||
window.ym(metricCounterNumber, "reachGoal", goal)
|
window.ym(metricCounterNumber, "reachGoal", goal)
|
||||||
console.log("goal: ", goal);
|
console.log("goal: ", goal);
|
||||||
|
|
||||||
if (!window._learnq) return console.error("Klaviyo.Metric not found");
|
if (!window.klaviyo) return console.error("Klaviyo.Metric not found");
|
||||||
window._learnq.push(['track', goal]);
|
window.klaviyo.push(['track', goal]);
|
||||||
}
|
}
|
||||||
|
|
||||||
type THitOptions = {
|
type THitOptions = {
|
||||||
|
|||||||
@ -28,7 +28,7 @@ declare global {
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
ym: any;
|
ym: any;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
_learnq: any;
|
klaviyo: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user