0
0
mirror of https://github.com/Maks1mS/free-ozon-dpr.git synced 2025-10-21 01:17:31 +03:00

more analytics

This commit is contained in:
2024-06-13 20:57:21 +03:00
parent 41a33e6516
commit c11e80178d
4 changed files with 55 additions and 12 deletions

32
src/analytics.js Normal file
View File

@@ -0,0 +1,32 @@
import { el } from "./utils.js";
class Analytics {
static event(name, data = undefined) {
if (typeof ym !== 'undefined') {
// eslint-disable-next-line no-undef
ym(window.YANDEX_METRICA_ID, 'reachGoal', name, data);
}
}
}
document.addEventListener("DOMContentLoaded", function () {
const popupPVZId = el("popup-pvz-id");
const pvzData = { pvz: popupPVZId.innerText };
const popupLink = el("popup-link");
const sourceLink = el("popup-source");
const infoPopupButton = el("info-popup-button");
popupLink.addEventListener("click", function () {
Analytics.event("pvz-link-clicked", pvzData);
});
sourceLink.addEventListener("click", function () {
Analytics.event("pvz-link-clicked", pvzData);
});
infoPopupButton.addEventListener("click", function () {
Analytics.event("info-popup-closed");
});
});

View File

@@ -93,7 +93,7 @@
<input type="checkbox" name="no-show">
Больше не показывать
</label>
<button>Я прочитал и понял прочитанное</button>
<button id="info-popup-button">Я прочитал и понял прочитанное</button>
</footer>
</div>
</div>

View File

@@ -4,6 +4,7 @@ import map from "./map";
import "./info-popup";
import "./popup";
import "./analytics";
import mergedData from "../merged-data.json";
import { createFeatures } from "./features";