PageSourceSearch

https://www.sprachreisen.org/assets/src/matomo_tracker-149211f805f…dc48d8fa8154b665b6ee927a6fb8584d3b76f794.js

js sprachreisen.org collected 2026-10-05 18:06:38 UTC 3,366 bytes, 122 lines download raw bytes

1import { isLocalRequest } from "src/utils"
2
3class MatomoTracker {
4
5  static load() {
6    if (MatomoTracker.siteId() !== null)  {
7      window._paq = window._paq || []
8      window._paq.push(['setTrackerUrl', MatomoTracker.trackerUrl() + '/matomo.php'])
9      window._paq.push(['setSiteId', MatomoTracker.siteId()])
10      window._paq.push(['enableLinkTracking'])
11
12      // Create a script element and insert it in the DOM
13      let script = document.createElement("script")
14      script.type = "text/javascript"
15      script.defer = true
16      script.async = true
17      script.src =  MatomoTracker.trackerUrl() + '/matomo.js'
18      let firstScript = document.getElementsByTagName("script")[0]
19      firstScript.parentNode.insertBefore(script, firstScript)
20
21      if (typeof(Turbo) !== 'undefined') {
22        document.addEventListener("turbo:load", (e) => {
23          console.debug("fired event", e.type)
24          console.debug("tracking matomo with refresh")
25          MatomoTracker.trackPageView('refresh')
26        }, true)
27      } else {
28        MatomoTracker.trackPageView()
29      }
30
31    } else {
32      console.warn("Matomo siteId is undefined")
33    }
34  }
35
36  static trackPageView(url) {
37    if (isLocalRequest() !== true) {
38      console.debug("matomo about to track pageView")
39      if (url !== null) {
40        if (url === 'refresh') {
41          console.debug("matomo: turbo refresh")
42          window._paq.push(['setCustomUrl', document.location.href])
43          window._paq.push(['setDocumentTitle', document.title])
44          window._paq.push(['trackPageView'])
45        } else {
46          window._paq.push(['trackPageView', url])
47        }
48      } else {
49        window._paq.push(['trackPageView'])
50      }
51    } else {
52      console.debug("no matomo tracking - its a localrequest")
53    }
54  }
55
56  static setUserId(userId) {
57    if (isLocalRequest() !== true) {
58      window._paq.push(['setUserId', userId])
59    }
60  }
61
62  static trackEcommerceView(sku) {
63    if (isLocalRequest() !== true) {
64      window._paq.push(['setEcommerceView', sku])
65    }
66  }
67
68  static trackGoal(id, price=0) {
69    if (isLocalRequest() !== true) {
70      window._paq.push(['trackGoal', id, price])
71    }
72  }
73
74  static trackEvent(category, action, name, value=0) {
75    if (isLocalRequest() !== true) {
76      window._paq.push(['trackEvent', category, action, name, value])
77    } else {
78      console.debug("trackEvent dummy - its a localrequest:", category, action, name, value)
79    }
80  }
81
82  static trackLink(url) {
83    if (isLocalRequest() !== true) {
84      window._paq.push(['trackLink', url, 'link'])
85    }
86  }
87
88  static addEcommerceItem(sku, name, category, price) {
89    if (isLocalRequest() !== true) {
90      window._paq.push(['addEcommerceItem', sku, name, category, parseFloat(price)])
91    }
92  }
93
94  static trackEcommerceOrder(orderId, revenue) {
95    if (isLocalRequest() !== true) {
96      window._paq.push(['trackEcommerceOrder', orderId, parseFloat(revenue)])
97    }
98  }
99
100  static trackEcommerceCartUpdate(sum) {
101    if (isLocalRequest() !== true) {
102      window._paq.push(['trackEcommerceCardUpdate', parseFloat(sum)])
103    }
104  }
105
106  static trackerUrl() {
107    return "https://stats.austauschkompass.de"
108  }
109
110  static siteId() {
111    return window.AK_TRACKING_MT_ID
112  }
113}
114
115const setupMatomoTracker = () => {
116  MatomoTracker.load()
117}
118
119export {
120  setupMatomoTracker,
121  MatomoTracker,
122};

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.