Issues (994)

libs/js/analystics.js (1 issue)

Labels
Severity
1
if (!(typeof module !== "undefined" && module.exports)) {
2
  var gtagID = "UA-106238155-1";
3
  var create_gtagscript = document.createElement("script");
4
  create_gtagscript.src =
5
    "https://www.googletagmanager.com/gtag/js?id=" + gtagID;
6
  create_gtagscript.async = true;
7
  document.getElementsByTagName("body")[0].appendChild(create_gtagscript);
8
  var gtag = null;
9
  window.onload = function () {
10
    if (window.dataLayer) {
11
      window.dataLayer = window.dataLayer || [];
12
13
      gtag = function () {
14
        window.dataLayer.push(arguments);
15
      };
16
      gtag("js", new Date());
17
      gtag("config", gtagID, {
18
        page_title: document.title,
19
        page_path: location.pathname,
20
      });
21
      gtag("event", "page_view", {
22
        send_to: gtagID,
23
      });
24
      gtag("config", "UA-106238155-1", {
25
        cookie_prefix: "GoogleAnalystics",
26
        cookie_domain: location.host,
27
        cookie_update: false, //true false update cookie every load
28
        cookie_expires: 28 * 24 * 60 * 60, // 28 days, in seconds
29
      });
30
31
      var trackLinks = document.getElementsByTagName("a");
32
      for (var i = 0, len = trackLinks.length; i < len; i++) {
33
        trackLinks[i].onclick = function () {
34
          if (!/^\#/gm.test(this.href) && !empty(this.href)) {
35
            gtag("event", "click", {
36
              event_category: "outbound",
37
              event_label: this.href,
38
              transport_type: "beacon",
39
            });
40
          }
41
        };
42
      }
43
44
      /*var elementsArray = document.querySelectorAll('b,iframe,ins,button,img,input,.adsense,#adsense,.ads,#ads,.ad_slot,.adsbygoogle,blockquote');
45
    elementsArray.forEach(function(elem) {
46
      elem.addEventListener("click", function(event) {
47
        var data = null;
48
        var clickon = "X: " + event.clientX + " - Y: " + event.clientY;
49
        
50
        dump = document.getElementById('positionTrack');
51
        
52
        if (dump) {
53
          data = this.tagName + '(' + clickon + ')';
54
          
55
          dump.textContent = data;
56
        }
57
        gtag("event", "ClickPosition", {
58
          'elements': data
59
        });
60
      });
61
    });*/
62
    }
63
  };
64
65
  /**
66
   * Google analystic reporter
67
   * @param {String} event_action
68
   * @param {string} event_label
69
   * @param {string} event_category
70
   * @param {string} event_value
71
   * @param {Function|any} event_callback
72
   */
73
  function analys(
0 ignored issues
show
The function analys is declared conditionally. This is not supported by all runtimes. Consider moving it to root scope or using var analys = function() { /* ... */ }; instead.
Loading history...
74
    event_action,
75
    event_label,
76
    event_category,
77
    event_value,
78
    event_callback
79
  ) {
80
    var conf = {
81
      event_label: event_label,
82
      event_category: event_category,
83
      value: event_value,
84
      event_callback:
85
        typeof event_callback == "function" ? event_callback : false,
86
    };
87
    return gtag("event", event_action, conf);
88
  }
89
}
90