Jump to content

Use properly "ProcessPageView::pageNotFound" hook ?


Recommended Posts

Posted

Hi

I would like to create a 404 page tracking. Then I hooked ProcessPageView::pageNotFound.

But If another plugin like Jumplinks for example redirect to another page, I don't want to track it any more like a 404 page...

I don't see which hook can I use to be sure to have a real 404 page.

Thanks for your help

Posted

What if you just add some code at the bottom of _main.php and check for the page id there?

<?php
if($page->id === 27) $site->track404();
?>

If Jumplinks kicks in, that should happen earlier I guess, so it should only track real 404 impressions?

  • 3 weeks later...
Posted

Hello @bernhard. Thanks for this tips. I tried it quickly, but the method $site->track404() runned even if there is a redirection after... I have to try in more detail !

Posted

Ok then maybe Jumplinks hooks after pageview and so that track404 is called nonetheless. You could also hook after pageview and make sure that your hook has a very low priority to make sure it fires at the very end (after all other modules that might have hooks attached).

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...