lpa Posted April 12 Share Posted April 12 I am trying to implement server level analytics calling Matomo PHP tracking API from page footer.php that is included in every template. When I call for a renamed page URL handled by a 301 redirect, it seems to go first to '/http404/'. The $_SERVER['REQUEST_URI'] for the call is '/oldpath/pagename/'. It is handled by '/http404/' having URL '/http404/pagename/' in URL column when logging with `$log->message($page->url)`. I don't understand what is really happening here. How should I detect that the requested path was '/oldpath/pagename/' and that it caused a 301 redirect and it should not be tracked in Matomo as a page load? Link to comment Share on other sites More sharing options...
lpa Posted April 14 Author Share Posted April 14 My straightforward question is: How can I determine on the '/http404/' page whether it's being accessed solely due to a redirect with a status code of 301 leading to the updated URL? Link to comment Share on other sites More sharing options...
wbmnfktr Posted April 15 Share Posted April 15 What about the referrer? Would this help? Haven't played around with error codes and 404 handling lately but I'd probably start with logging the referrer page in some way at least. I guess $_SERVER['HTTP_REFERER'] might work here. Totally untested and just an idea for now. Link to comment Share on other sites More sharing options...
lpa Posted April 16 Author Share Posted April 16 It seems to me, that the http404-page is rendered before the decission to redirect to the page in page path history is done. I would like to know when rendering http404, that there will be a redirect and the http404 page should not be tracked in Matomo as a page load. But I can't figure out how to detect this. HTTP_REFERER does not help, as I am interested to detect the forthcoming 301 before the 404 page is rendered. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now