PageSourceSearch

https://www.medical-hub.berlin-chemie.de/sites/g/files/fugoka451/f…/analytics/analytics-events.js?tkbxkr

js berlin-chemie.de collected 2026-09-24 10:12:12 UTC 3,294 bytes, 90 lines download raw bytes

1(function ($, Drupal, once) {
2  "use strict";
3
4  Drupal.behaviors.AnalyticsEvents = {
5    attach: function (context, settings) {
6
7        function fireEvent(type) {
8            // GA is enabled, so carry on and create the events got all matching elements.
9            $(once('coh-js-analytics-init', '[data-analytics]')).each(function () {
10
11                // Save the element reference.
12                var element = $(this);
13
14                // Decode the analytics JSON from the data attribute.
15                var events = JSON.parse($(this).attr('data-analytics'));
16
17                // Loop through this attribute object, creating an event for each entry.
18                events.forEach(function (event) {
19
20                    event.hitType = 'event';    // Populate the GA data object.
21                    element.bind(event.trigger, function (e, inView) {
22
23                        // inview trigger fired, but element left the viewport.
24                        if (e.type === 'inview' && !inView) {
25                            return;
26                        }
27
28                        // Fire the GA event according to: https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits
29                        var trackerName;
30
31                        try {
32                            var trackers = type.getAll();
33                            var firstTracker = trackers[0];
34
35                            var activeKey;
36                            if (typeof firstTracker.a !== 'undefined') {
37                                activeKey = 'a';
38                            }
39                            if (typeof firstTracker.b !== 'undefined') {
40                                activeKey = 'b';
41                            }
42
43                            trackerName = firstTracker[activeKey].data.values[":name"] + '.';
44
45                            if (typeof event.trigger !== 'undefined') {
46                                delete event.trigger;
47                            }
48                        }
49                        catch (e) {
50                            trackerName = '';
51                        }
52
53                        // Universal Analytics
54                        if(type === 'gtag') {
55                            gtag('event', event.eventAction, {
56                                'event_category': event.eventCategory,
57                                'event_label': event.eventLabel,
58                                'event_value': event.eventValue
59                            });
60                        }
61
62                        // Classic Analytics
63                        if(type === 'ga') {
64                            ga(trackerName + 'send', 'event', event);
65                        }
66                    });
67
68                });
69
70            });
71        }
72
73        // Check to see if gtag() function is available .
74        if (typeof gtag !== 'undefined') {
75            fireEvent('gtag');
76        }
77
78        // Check to see if ga() function is available.
79        if (typeof ga === typeof Function) {
80            fireEvent('ga');
81        }
82
83        // GA not available, so warn.
84        else {
85            console.warn('Google Analytics is not available, but GA events have been defined.');
86        }
87     }
88  };
89
90})(jQuery, Drupal, once);

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.