PageSourceSearch

https://ponyexpress.kz/local/templates/ponyexpress_main/js/ingevents.js

js ponyexpress.kz collected 2026-09-26 09:55:49 UTC 5,544 bytes, 177 lines download raw bytes

1/* ver. 3.2.1 */
2var ingEventsConfig = {
3	debug: false, //debug mode
4	idYM: ['15069907'],   //Yandex Metrika id array
5	idGA: [],   //GA tracking name array
6	idGT: []    //GA tracking id array
7};
8
9function ingEvents(params, config) {
10	var debug = config.debug;
11	var counters = [];
12	var idYM = config.idYM;
13	var idGA = config.idGA;
14	var idGT = config.idGT;
15
16	//Search Yandex Metrika tracking ids
17	if (!idYM.length && window.Ya && window.Ya._metrika) {
18		var key;
19		for (key in window.Ya._metrika.hitParam) {
20			if (!window.Ya._metrika.hitParam.hasOwnProperty(key)) {
21				continue;
22			}
23			idYM.push(parseInt(key));
24		}
25	}
26	//Search GA tracking names and ids
27	if (typeof ga !== "undefined" && !idGT.length && !idGA.length) {
28		var ga_trackers = [];
29		ga(function () {
30			ga_trackers = ga.getAll();
31			ga_trackers.forEach(function (item, i, arr) {
32				var ga_name = item.get('name');
33				var ga_tid = item.get('trackingId');
34				if (ga_name == 't0') {
35					idGA.push('send');
36				}
37				if (/^(gtag_UA_.*)$/g.exec(ga_name) === null && ga_name != 't0') {
38					idGA.push(ga_name + '.send');
39				}
40				idGT.push(item.get('trackingId'));
41			});
42		});
43	}
44
45	// Cheking parameters
46	if (typeof params !== "undefined") {
47		// Cheking GA parameters
48		if (typeof params.category !== "undefined" && typeof params.action !== "undefined" && typeof params.label !== "undefined") {
49			// Search pageTracker
50			if (typeof pageTracker !== "undefined") {
51				pageTracker._trackEvent(params.category, params.action, params.label);
52				ingEventsCallback('Google', params, debug);
53				counters.push('pageTracker');
54			}
55			// Search tracker ga.js
56			if (typeof _gaq !== "undefined") {
57				_gaq.push(['_trackEvent', params.category, params.action, params.label]);
58				ingEventsCallback('Google', params, debug);
59				counters.push('_gaq');
60			}
61			// Search tracker analytics.js
62			if (typeof ga !== "undefined") {
63				for (i = 0; i < idGA.length; i++) {
64					ga(idGA[i], 'event', params.category, params.action, params.label, {hitCallback: ingEventsCallback('Google', params, debug)});
65					counters.push('ga(' + idGA[i] + ')');
66				}
67			}
68			// Search tracker gtag.js
69			if (typeof gtag !== "undefined") {
70				gtag('event', params.action, {'event_category': params.category, 'event_label': params.label});
71				ingEventsCallback('Google', params, debug);
72				counters.push('gtag');
73			}
74		}
75		if (typeof params.ga_page !== "undefined") {
76			// Search tracker ga.js
77			if (typeof _gaq !== "undefined") {
78				_gaq.push(['_trackPageview', params.ga_page]);
79				ingEventsCallback('Google', params, debug);
80				counters.push('_gaq');
81			}
82			// Search tracker analytics.js
83			if (typeof ga !== "undefined") {
84				for (i = 0; i < idGA.length; i++) {
85					ga(idGA[i], 'pageview', params.ga_page, {hitCallback: ingEventsCallback('Google', params, debug)});
86					counters.push('ga(' + idGA[i] + ')');
87				}
88			}
89			// Search tracker gtag.js
90			if (typeof gtag !== "undefined") {
91				for (i = 0; i < idGT.length; i++) {
92					gtag('event', 'page_view', {'send_to': idGT[i], 'page_path': params.ga_page});
93					ingEventsCallback('Google', params, debug);
94					counters.push('gtag(' + idGT[i] + ')');
95				}
96			}
97		}
98
99		if (typeof params.ya_label == "undefined" && typeof params.ya_page !== "undefined") {
100			params.ya_label = params.ya_page;
101		}
102		// Cheking YM parameters
103		if (typeof params.ya_label !== "undefined") {
104			if (typeof params.goalParams == "undefined") {
105				params.goalParams = {};
106			}
107			for (i = 0; i < idYM.length; i++) {
108				// Checking YM
109				if (typeof window['yaCounter' + idYM[i]] !== "undefined") {
110					// Call YM reachGoal
111					window['yaCounter' + idYM[i]].reachGoal(params.ya_label, params.goalParams, ingEventsCallback('Yandex', params, debug));
112					counters.push('yaCounter' + idYM[i]);
113				}
114			}
115		}
116		ingEventsLog(counters, debug);
117	}
118}
119
120// Log trackers on the page
121function ingEventsLog(counters, debug) {
122	if (debug === true) {
123		console.log('Events script version: 3.2.1\n')
124		if (counters.length === 0) {
125			console.log('Сounters:\n\tnone');
126		} else {
127			console.log('Сounters:\n\t' + counters);
128		}
129	}
130}
131
132// GA and YM callback function
133function ingEventsCallback(name, params, debug) {
134	var msg = '';
135	if (debug === true) {
136		if (typeof params.ga_page !== "undefined" || typeof params.ya_page !== "undefined") {
137			msg = name + ' pageview reached:\n\t';
138		} else {
139			msg = name + ' event reached:\n\t';
140		}
141		if (name == 'Yandex') {
142			if (typeof params.ya_page !== "undefined") {
143				msg = msg + '[ya_page : ' + params.ya_label + ']\n';
144			} else {
145				msg = msg + '[ya_label : ' + params.ya_label + ']\n';
146			}
147		}
148		if (name == 'Google') {
149			if (typeof params.ga_page !== "undefined") {
150				msg = msg + '[ga_page : ' + params.ga_page + ']\n';
151			} else {
152				msg = msg + '[category : ' + params.category + ']\n\t[action   : ' + params.action + ']\n\t[label    : ' + params.label + ']\n';
153			}
154		}
155		console.log(msg);
156	}
157}
158
159// Lagacy proxy functions
160function ing_events(params) {
161	try {
162		if (typeof params.ya_label == "undefined" && typeof params.label !== "undefined") {
163			params.ya_label = params.label;
164		}
165		ingEvents(params, ingEventsConfig);
166	} catch (e) {
167		console.log(e.message);
168	}
169}
170
171function ing_pageview(params) {
172	try {
173		ingEvents({ga_page: params.page, ya_page: params.label}, ingEventsConfig);
174	} catch (e) {
175		console.log(e.message);
176	}
177}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.