PageSourceSearch

https://www.makaliauslietuva.lt/wp-content/themes/makaliuslithuania/js/makalius_ga.js?v=20260812

js makaliauslietuva.lt collected 2026-10-08 06:12:07 UTC 2,426 bytes, 90 lines download raw bytes

1/**
2 * Universal Analytics → GA4 converter.
3 * Keeps legacy ga('send', ...) calls working via gtag.
4 */
5(function (window) {
6    function toEventName(value) {
7        var name = String(value || 'custom_event')
8            .toLowerCase()
9            .replace(/ą/g, 'a').replace(/č/g, 'c').replace(/ę/g, 'e').replace(/ė/g, 'e')
10            .replace(/į/g, 'i').replace(/š/g, 's').replace(/ų/g, 'u').replace(/ū/g, 'u').replace(/ž/g, 'z')
11            .replace(/[^a-z0-9]+/g, '_')
12            .replace(/^_+|_+$/g, '')
13            .substring(0, 40);
14
15        if (!name) {
16            name = 'custom_event';
17        }
18
19        if (!/^[a-z]/.test(name)) {
20            name = 'event_' + name;
21        }
22
23        return name;
24    }
25
26    function sendEvent(category, action, label, value) {
27        if (typeof gtag !== 'function') {
28            return;
29        }
30
31        var params = {
32            event_category: category,
33            event_label: typeof label !== 'undefined' && label !== null ? label : action,
34            event_action: action
35        };
36
37        if (typeof value === 'number') {
38            params.value = value;
39        }
40
41        gtag('event', toEventName(action || category), params);
42    }
43
44    function sendPageView(pagePath) {
45        if (typeof gtag !== 'function') {
46            return;
47        }
48
49        gtag('event', 'page_view', {
50            page_path: pagePath || window.location.pathname
51        });
52    }
53
54    window.ga = function () {
55        var args = Array.prototype.slice.call(arguments);
56        var command = args[0];
57        var hitType;
58        var fields;
59
60        if (command !== 'send') {
61            return;
62        }
63
64        if (typeof args[1] === 'object' && args[1] !== null) {
65            fields = args[1];
66            hitType = fields.hitType;
67        } else {
68            hitType = args[1];
69            fields = {
70                eventCategory: args[2],
71                eventAction: args[3],
72                eventLabel: args[4],
73                eventValue: args[5],
74                page: args[2]
75            };
76        }
77
78        if (hitType === 'event') {
79            sendEvent(fields.eventCategory, fields.eventAction, fields.eventLabel, fields.eventValue);
80            return;
81        }
82
83        if (hitType === 'pageview') {
84            sendPageView(fields.page);
85        }
86    };
87
88    window.ga.l = 1 * new Date();
89    window.ga.q = window.ga.q || [];
90})(window);

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.