-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added 404 support #619
base: master
Are you sure you want to change the base?
Added 404 support #619
Conversation
The footer partial is still loaded when the I wonder if this creates two tracking events in Matomo? Looking at the documentation[1], it seems like you can push the [1] https://developer.matomo.org/guides/tracking-javascript-guide |
From what I'm getting you'd have to use a separate tracking event for the 404 page (Since you can't really check if the page you're on is 404 from JavaScript unless you use something like fetch), I didn't realize the footer partial is loaded 🤔 I don't see any reference for it in the 404 page layout. I've sent a PR for the wikis 404 tracking it has the same boundaries regarding a separate tracking instance, I've written there in more detail. I'll check how I can bypass that on Sunday. |
You wouldn't need a separate tracking event. They're leveraging Pseudo-Example of what the snippet does to the title when reporting it to Matomo:
Then, you'd be able to quickly view, filter, and identify the page causing a 404 and where it's coming from inside Matomo ( I think you can push the
I haven't tested this, but if that works, it should be as easy as removing the tracking portion you added but keeping the |
So I just insert a script tag with this line? _paq.push(['setDocumentTitle', '404/URL = ' + encodeURIComponent(document.location.pathname+document.location.search) + ' /From = ' + encodeURIComponent(document.referrer)]); From my understanding this would have to be located before And it is already called in the footer layout partial, that's why I created a new tracking event with the new document title in the first place (When I thought it wasn't tracking at all). I think I'm missing something... 🙃 At first, I wanted to detect a 404 status code and then change the document title in the tracking event dynamically (this proved to be not the best idea) but it seems better to just use the 404 page template with a modified tracking event (or script tag) 🤷♂️ let me know what you think we should do. |
Give something like this a try. You can see what's being sent to Matomo by viewing your network inspector. master...codyro:almalinux.org:matomo-404-test References |
Unlike this issue AlmaLinux/wiki#467 for the wiki, it was much simpler to implement this since the script tag for matomo tracking was present in the footer layout partial and it was not used on the 404 page layout.
As you can see it was as simple as inserting the tracking script tag and adding this line:
As said in this guide.
Let me know if this works.
Referring to this issue - #603.