|
34 | 34 | ].join(", ");
|
35 | 35 | const outbound_url_selector = `a[href^="${window.location.origin}"]:not([href^="#"]):not([href^="."])`;
|
36 | 36 |
|
37 |
| - console.debug("mode_production", mode_production); |
38 |
| - console.debug("mode_staging", mode_staging); |
39 |
| - console.debug("mode_development", mode_development); |
40 |
| - console.debug("tracking_endpoint_url", tracking_endpoint_url); |
41 |
| - console.debug("tracking_domain", tracking_domain); |
42 |
| - console.debug("site_id", site_id); |
| 37 | + console.debug("Matomo: mode_production", mode_production); |
| 38 | + console.debug("Matomo: mode_staging", mode_staging); |
| 39 | + console.debug("Matomo: mode_development", mode_development); |
| 40 | + console.debug("Matomo: tracking_endpoint_url", tracking_endpoint_url); |
| 41 | + console.debug("Matomo: tracking_domain", tracking_domain); |
| 42 | + console.debug("Matomo: site_id", site_id); |
43 | 43 |
|
44 | 44 | let previous_url = location.href;
|
45 | 45 |
|
|
101 | 101 | if (url_elems.length >1) {
|
102 | 102 | vars_url = vars_url + '?' + url_elems[1];
|
103 | 103 | }
|
104 |
| - console.log(vars_url); |
105 | 104 |
|
106 | 105 | const response = await fetch(vars_url, {
|
107 | 106 | headers: { "Accept": "application/json" },
|
|
111 | 110 | }
|
112 | 111 |
|
113 | 112 | const data = await response.json();
|
114 |
| - console.log("📌 Loaded Piwik Variables:", data); |
| 113 | + console.debug("Matomo: 📌 Loaded Piwik Variables:", data); |
115 | 114 | return data;
|
116 | 115 | } catch (error) {
|
117 |
| - console.error("❌ Error loading Piwik variables:", error); |
| 116 | + console.error("Matomo: ❌ Error loading Piwik variables:", error); |
118 | 117 | return null;
|
119 | 118 | }
|
120 | 119 | }
|
121 | 120 |
|
122 | 121 | async function compile_tracking_variables() {
|
| 122 | + console.debug("Matomo: Tracking triggered."); |
| 123 | + |
| 124 | + |
123 | 125 | // Wait for JSON data before proceeding
|
124 | 126 | // TODO: ENABLE for scrum-3351
|
125 | 127 | //const tracking_dimensions = await load_tracking_dimensions();
|
126 | 128 | const tracking_dimensions = {};
|
127 | 129 |
|
128 | 130 | if (!tracking_dimensions) {
|
129 |
| - console.error("❌ No Piwik data loaded, skipping tracking."); |
| 131 | + console.error("Matomo: ❌ No Piwik data loaded, skipping tracking."); |
130 | 132 |
|
131 | 133 | // Fall back to tracking dimensions from the template.
|
132 | 134 | // TODO: this code can probably be removed when scrum-3351 is rolled-out.
|
|
136 | 138 | tracking_dimensions.language_code = document.getElementById('language_code').innerHTML;
|
137 | 139 | //return;
|
138 | 140 | }
|
139 |
| - console.log("✅ Matomo tracking initialized with custom variables."); |
| 141 | + console.debug("Matomo: ✅ tracking initialized with custom variables."); |
140 | 142 |
|
141 | 143 | // Custom variables
|
142 | 144 | _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
|
|
194 | 196 | document.addEventListener("patterns-injected-delayed", function() {
|
195 | 197 | // Track page injections with history changes.
|
196 | 198 | if (previous_url !== location.href) {
|
| 199 | + console.debug("Matomo: pat-inject triggered tracking."); |
197 | 200 | // Only track if the URL has changed
|
198 | 201 | previous_url = location.href;
|
199 | 202 | // reload tracking variables after navigating without a page reload.
|
|
0 commit comments