Developer forum

Forum » Templates » Detect statuscode 404 in template

Detect statuscode 404 in template

Martin Nielsen
Reply

Hi DW,

I'm trying to detect whether a given page returned 404 statuscode or not.
I want to do this to send a different tracking code to Google Analytics when the page wasn't found.

I'm doing this which works fine:

  <!--@If(Global:Request.Url<contains>'/admin/public/404.aspx')-->
  _gaq.push(['_trackPageview','my special tracking']);
  <!--@Else-->
  _gaq.push(['_trackPageview']);
  <!--@EndIf-->

But is there a better way?

// Martin


Replies

 
Nicolai Høeg Pedersen
Reply

Well, if the 404 handler is setup as described, and you have defined a page that should be the 404 page, you can test on the Page ID or only have the special tracking in a 404 paragraph template on that page.
 

 

You must be logged in to post in the forum