yandex-metrika-vue3
Version:
**yandex-metrika-vue3** allows you to send data about visited pages to [Yandex Metrika]. ## Installation Install with [yarn]: ```bash $ yarn add yandex-metrika-vue3 ``` Install with [npm]: ```bash $ npm install yandex-metrika-vue3 --save ``` ## Ways to us
84 lines (83 loc) • 2.89 kB
JavaScript
import { prepareEcommerceDataLayer } from './ecommerce.js';
export class YaMetrikaObject {
constructor() {
this.metrika = null;
}
setMetrika(metrika) {
this.metrika = metrika;
this._setFunctions();
}
addFileExtension(vals) {
console.error('Method not implemented.');
}
extLink(url, options) {
console.error('Method not implemented.');
}
file(url, options) {
console.error('Method not implemented.');
}
getClientID(callback) {
console.error('Method not implemented.');
}
hit(url, options) {
console.error('Method not implemented.');
}
notBounce(options) {
console.error('Method not implemented.');
}
params(parameters) {
console.error('Method not implemented.');
}
reachGoal(target, params, callback, ctx) {
console.error('Method not implemented.');
}
replacePhones() {
console.error('Method not implemented.');
}
setUserID(userID) {
console.error('Method not implemented.');
}
userParams(parameters) {
console.error('Method not implemented.');
}
ecommerceImpressions(data) {
this.pushToDatalayer(data);
}
ecommerceClick(data) {
this.pushToDatalayer(data);
}
ecommerceDetail(data) {
this.pushToDatalayer(data);
}
ecommerceAdd(data) {
this.pushToDatalayer(data);
}
ecommerceRemove(data) {
this.pushToDatalayer(data);
}
ecommercePurchase(data) {
this.pushToDatalayer(data);
}
_setFunctions() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
const m = this.metrika;
if (!m) {
return;
}
this.addFileExtension = (_a = m.addFileExtension) === null || _a === void 0 ? void 0 : _a.bind(m);
this.extLink = (_b = m.extLink) === null || _b === void 0 ? void 0 : _b.bind(m);
this.file = (_c = m.file) === null || _c === void 0 ? void 0 : _c.bind(m);
this.getClientID = (_d = m.getClientID) === null || _d === void 0 ? void 0 : _d.bind(m);
this.hit = (_e = m.hit) === null || _e === void 0 ? void 0 : _e.bind(m);
this.notBounce = (_f = m.notBounce) === null || _f === void 0 ? void 0 : _f.bind(m);
this.params = (_g = m.params) === null || _g === void 0 ? void 0 : _g.bind(m);
this.reachGoal = (_h = m.reachGoal) === null || _h === void 0 ? void 0 : _h.bind(m);
this.replacePhones = (_j = m.replacePhones) === null || _j === void 0 ? void 0 : _j.bind(m);
this.setUserID = (_k = m.setUserID) === null || _k === void 0 ? void 0 : _k.bind(m);
this.userParams = (_l = m.userParams) === null || _l === void 0 ? void 0 : _l.bind(m);
}
pushToDatalayer(data) {
prepareEcommerceDataLayer();
window.dataLayer.push({ ecommerce: data });
}
}