PageSourceSearch

https://byoghavn.dk/wp-content/plugins/ajax-search-pro/js/nomin/plugin/optimized/asp-ga.js

js byoghavn.dk collected 2026-10-01 10:43:43 UTC 4,118 bytes, 96 lines download raw bytes

1(function($){
2    "use strict";
3    let functions = {
4        gaEvent: function(which, data) {
5            let $this = this;
6            let tracking_id = $this.gaGetTrackingID();
7            // noinspection JSUnresolvedVariable
8            if ( typeof ASP.analytics == 'undefined' || ASP.analytics.method != 'event' )
9                return false;
10
11            // Get the scope
12            let _gtag = typeof gtag == "function" ? gtag : false;
13
14            if ( _gtag === false && typeof window.dataLayer == 'undefined' )
15                return false;
16
17            // noinspection JSUnresolvedVariable
18            if (
19                typeof (ASP.analytics.event[which]) != 'undefined' &&
20                ASP.analytics.event[which].active == 1
21            ) {
22                let def_data = {
23                    "search_id": $this.o.id,
24                    "search_name": $this.n('search').data('name'),
25                    "phrase": $this.n('text').val(),
26                    "option_name": '',
27                    "option_value": '',
28                    "result_title": '',
29                    "result_url": '',
30                    "results_count": ''
31                };
32                // noinspection JSUnresolvedVariable
33                let event = {
34                    'event_category': ASP.analytics.event[which].category,
35                    'event_label': ASP.analytics.event[which].label,
36                    'value': ASP.analytics.event[which].value
37                };
38                data = $.fn.extend(def_data, data);
39                Object.keys(data).forEach(function (k) {
40                    let v = data[k];
41                    v = String(v).replace(/[\s\n\r]+/g, " ").trim();
42                    Object.keys(event).forEach(function (kk) {
43                        let regex = new RegExp('\{' + k + '\}', 'gmi');
44                        event[kk] = event[kk].replace(regex, v);
45                    });
46                });
47                if ( _gtag !== false ) {
48                    if ( tracking_id !== false ) {
49                        tracking_id.forEach(function(id){
50                            event.send_to = id;
51                            // noinspection JSUnresolvedVariable
52                            _gtag('event', ASP.analytics.event[which].action, event);
53                        });
54                    } else {
55                        // noinspection JSUnresolvedVariable
56                        _gtag('event', ASP.analytics.event[which].action, event);
57                    }
58                } else if ( typeof window.dataLayer.push != 'undefined' ) {
59                    window.dataLayer.push({
60                        'event': 'asp_event',
61                        'event_name': ASP.analytics.event[which].action,
62                        'event_category': event.event_category,
63                        'event_label': event.event_label,
64                        'event_value': event.value
65                    });
66                }
67            }
68        },
69
70        gaGetTrackingID: function() {
71            let ret = false;
72            // noinspection JSUnresolvedVariable
73            if ( typeof ASP.analytics == 'undefined' )
74                return ret;
75
76            // noinspection JSUnresolvedVariable
77            if ( typeof ASP.analytics.tracking_id != 'undefined' && ASP.analytics.tracking_id != '' ) {
78                // noinspection JSUnresolvedVariable
79                return [ASP.analytics.tracking_id];
80            } else {
81                // GTAG bypass pageview tracking method
82                let _gtag = typeof window.gtag == "function" ? window.gtag : false;
83                if ( _gtag === false && typeof window.ga != 'undefined' && typeof window.ga.getAll != 'undefined' ) {
84                    let id = [];
85                    window.ga.getAll().forEach( function(tracker) {
86                        id.push( tracker.get('trackingId') );
87                    });
88                    return id.length > 0 ? id : false;
89                }
90            }
91
92            return ret;
93        }
94    }
95    $.fn.extend(window.WPD.ajaxsearchpro.plugin, functions);
96})(WPD.dom);

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.