Goal
On my Website I have a Search whithout Parameters in the URL. I want to track the Seachwords via Matomo for further analytics.
Important Infos
On the Website a Matomo Tag Manager and the Matono JavaScript is included. The Matomo JavaScript is only there for the OnSite Seachtword Tracking.
Problem
[2025-05-07 06:19:49] piwik.DEBUG: Detected Site Search keyword 'TestWord'. [] {"class":"Actions","request_id":"2acda"}
[2025-05-07 06:19:49] piwik.DEBUG: NOTE: The Page URL was changed / removed, during the Site Search detection, was 'https://example.de/', now is '' [] {"class":"Actions","request_id":"2acda"}
I already checked:
- Latest Matomo version (5.3.2)
- My Testing IP Adress was not ignored
- Site Search Enabled: Admin > Websites > Site Search is enabled
- Tracking Request gets triggerd and searchword is sent to /matomo.php?search=Revier
- In enabled Tracking Debug there is show, that the parameters are set correctly
- The URL in the request is a valid absolute URL corresponds to Tracking URL in Matomo Admin
- Before the search, Matomo is correctly registering page view actions with valid URLs
- There are no JavaScript Errors
- Tested in inkognito Browser
What I tried and did not solve the problem
- Setting a custom URL right before the trackSiteSearch
- Removing Matomo Tag Manager Script
Concrete implementation
<header>
<!-- Matomo Tag Manager -->
<script>
var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://matomo.doubleslash.de/js/container_abcdef.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Tag Manager -->
<!-- Matomo JS Tracking -->
<script>
var _paq = window._paq = window._paq || [];
_paq.push(['requireConsent']); // for borlabs cookie banner
(function() {
var u="https://example.de/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo JS Tracking -->
</header>
<body>
<input class="jet-search-filter__input jet-input-not-empty" type="search" autocomplete="off" name="query" value="" placeholder="Welches Thema interessiert Dich?" aria-label="Durchsuche Beiträge" tabindex="0">
<script>
jQuery(document).ready(function () {
(function waitForMatomo(callback) {
if (window._paq && typeof window._paq.push === 'function') {
callback();
} else {
setTimeout(function() {
waitForMatomo(callback);
}, 100); // prüft alle 100ms erneut
}
})
(function() {
const searchInput = document.querySelector('input.jet-search-filter__input[type="search"]');
if (!searchInput) return;
let debounceTimer;
let lastTrackedSearchWord = '';
searchInput.addEventListener('input', function() {
clearTimeout(debounceTimer);
const searchWord = this.value.trim();
if (searchWord === '') return;
debounceTimer = setTimeout(function() {
if (searchWord === '') return;
if (searchWord && searchWord !== lastTrackedSearchWord) {
lastTrackedSearchWord = searchWord;
console.log('trackSiteSearch:', searchWord, ' on ' + window.location.href);
_paq.push(['trackSiteSearch',searchWord]);
}
}, 1000);
});
});
});
</script>
</body>
Do you happen to know what could be causing this?
Or how I can proceed here to determine the actual source of the error?
Perhaps you have already had this problem or a similar one and can help me here.
Thanks, Amelie