Deeper page not found wisdom with Google Analytics?

Options

I'm about to migrate a site with 1400+ pages onto Convio CMS.  There will be 404s aplenty (ie page-not-found errors), and I need to know what's generating them so that I can address the ones that matter.

I also believe that 404s are something that every webmaster should be tracking.

I'm reading in the support pages that Convio CMS offers no reporting mechanism for 404/page not found errors.  Is this true?

I'm considering working with this solution from Google Analytics:

http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=86927

... that involves setting up some javascript to record page metadata to the GA 'view' so that it shows in reports.

Has anyone played with this approach? Does the Convio 404 mechanism allow this approach to work? Are there other bits of cleverness that I should consider?

And yes, I'm aware of link checkers and whatnot, but running a link-checker wouldn't tell me if there's an incorrect vanityURL floating out there that people are trying to use.

thanks!

Tagged:

Comments

  • Alex,

    You can do that with a conditional like this in your wrapper:



    <t:if test="matches(path,'/404.html')">
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl ." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + " google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try{
    var pageTracker = _gat._getTracker("UA-xxxxx-x");
    pageTracker._trackPageview("/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer);
    } catch(err) {}
    </script>
    </t:if>
    <t:else>

    </t:else>

    Where /404.html is your File Not Found page as configured in CMS (and UA-xxxxx-x is of course your actual UA ).

  • Noah Cooper:

    Alex,

    You can do that with a conditional like this in your wrapper:



    <t:if test="matches(path,'/404.html')">
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl ." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + " google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try{
    var pageTracker = _gat._getTracker("UA-xxxxx-x");
    pageTracker._trackPageview("/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer);
    } catch(err) {}
    </script>
    </t:if>
    <t:else>

    </t:else>

    Where /404.html is your File Not Found page as configured in CMS (and UA-xxxxx-x is of course your actual UA ).

    Hey Noah, thanks so much for the quick reply.  I've worked with a lot of CMS' in the past, but not so much with Convio yet.

    When I tried this approach with another CMS, the document.location.pathname was coming back as 404.html, instead of the page that was deemed not found, so the approach was basically useless.

    I was hoping to find out ahead of time whether anyone had already played with this sort of thing in the Convio CMS.

    ..A

  • Alex Bernardin:

    Hey Noah, thanks so much for the quick reply.  I've worked with a lot of CMS' in the past, but not so much with Convio yet.

    When I tried this approach with another CMS, the document.location.pathname was coming back as 404.html, instead of the page that was deemed not found, so the approach was basically useless.

    I was hoping to find out ahead of time whether anyone had already played with this sort of thing in the Convio CMS.

    ..A

    Gotcha. In Convio CMS, document.location.pathname will return the page that was requested.

  • Thanks again Judah for your confirmation. It helped because I tried to test this and it failed, but your post made me look more closely.

    The key discovery that I would add to Judah's comment is that if you put this JS code into the body of the 404 page, it will execute when you have the page editor open. So in my 404 page, I was getting 'body-edit.jsp' as the document.pathname.  But when I looked more closely, I was able to verify that it also executes at page delivery, and so it works the way that it needs to.

    Putting that code in the wrapper would presumably avoid my little snafu, as long as you make sure that you have the correct pathname of your 404 page.

    Follow up question to make my code more bulletproof - is there a Convio template directive to get the current pathname of the 404 page programmatically? It would be hard to notice a dropoff in 404 reporting if I introduce a different page as the site 404...

    hm. I suppose I could use JS to trigger it, but that would be a bit stickier...

    ..A

  • Alex Bernardin:

    Thanks again Judah for your confirmation. It helped because I tried to test this and it failed, but your post made me look more closely.

    The key discovery that I would add to Judah's comment is that if you put this JS code into the body of the 404 page, it will execute when you have the page editor open. So in my 404 page, I was getting 'body-edit.jsp' as the document.pathname.  But when I looked more closely, I was able to verify that it also executes at page delivery, and so it works the way that it needs to.

    Putting that code in the wrapper would presumably avoid my little snafu, as long as you make sure that you have the correct pathname of your 404 page.

    Follow up question to make my code more bulletproof - is there a Convio template directive to get the current pathname of the 404 page programmatically? It would be hard to notice a dropoff in 404 reporting if I introduce a different page as the site 404...

    hm. I suppose I could use JS to trigger it, but that would be a bit stickier...

    ..A

    ** It's come to my attention that you were really looking for a variable that renders whatever page is currently set as the 404 page. Sorry for the confusion! **

    Why yes there is! In Convio CMS, the template syntax is ${path}. That will render on any 404 page as /404.html (or whatever the name of your 404 page is, if you've changed it). Here's what the code would look like:


    <t:if test="matches(path,'/404.html')"><br> <script type="text/javascript"><br> var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl ." : "<a href="http://www." target="_blank" rel="nofollow">http://www.</a>");<br> document.write(unescape("%3Cscript src='" + gaJsHost + " google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));<br> </script><br> <script type="text/javascript"><br> try{<br> var pageTracker = _gat._getTracker("UA-xxxxx-x");<br> pageTracker._trackPageview("<strong>${path}</strong>?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer);<br> } catch(err) {}<br> </script><br></t:if><br><t:else><br> <br></t:else><br>

    Drawing this distinction carefully: When you visit a nonexistent page in Convio CMS, the system will maintain your erroneous URL in the browser address bar, but the actual content it displays is drawn from your 404.html page.

    JavaScript is client-side, and doesn't know anything about the CMS filesystem; it's only aware of the URL in your address bar, so the document.location.pathname will display the page you were trying to access.

    The CMS template syntax renders the page that CMS is actually displaying. ${path} is server-side, and it  so it will render before the HTML actually arrives at your browser; if you use my code above, then reload a 404 page and View Source in your browser, you'll see that ${path} turned into /404.html.

  • James Zetlen:

    ** It's come to my attention that you were really looking for a variable that renders whatever page is currently set as the 404 page. Sorry for the confusion! **

    Why yes there is! In Convio CMS, the template syntax is ${path}. That will render on any 404 page as /404.html (or whatever the name of your 404 page is, if you've changed it). Here's what the code would look like:


    <t:if test="matches(path,'/404.html')"><br> <script type="text/javascript"><br> var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl ." : "<a href="http://www." target="_blank" rel="nofollow">http://www.</a>");<br> document.write(unescape("%3Cscript src='" + gaJsHost + " google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));<br> </script><br> <script type="text/javascript"><br> try{<br> var pageTracker = _gat._getTracker("UA-xxxxx-x");<br> pageTracker._trackPageview("<strong>${path}</strong>?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer);<br> } catch(err) {}<br> </script><br></t:if><br><t:else><br> <br></t:else><br>

    Drawing this distinction carefully: When you visit a nonexistent page in Convio CMS, the system will maintain your erroneous URL in the browser address bar, but the actual content it displays is drawn from your 404.html page.

    JavaScript is client-side, and doesn't know anything about the CMS filesystem; it's only aware of the URL in your address bar, so the document.location.pathname will display the page you were trying to access.

    The CMS template syntax renders the page that CMS is actually displaying. ${path} is server-side, and it  so it will render before the HTML actually arrives at your browser; if you use my code above, then reload a 404 page and View Source in your browser, you'll see that ${path} turned into /404.html.

    Hey james,

      Helpful information, thank you! I understand the path variable, and it's extremely useful to know how Convio CMS is distinguishing between the requested URL and the served file.

      I'm thinking now about the code for the Convio wrapper - the code we're talking about does a simple pattern match to see if it's serving the 404 content, so that it will output Javascript that will put useful information into Google Analytics.  That's cool.  Now fastforward 6-12 months... the brilliant young coding gun who takes over my job when I win the lottery decides that 404.html is a lousy name for a page-not-found, so she renames that page (in Convio) 'not-found.html'.  And our clever wrapper code that was matching on '404.html' no longer matches the way that it's intended to.

      Is there any way to make the pattern matching code safe from that kind of change? That's what I meant by is there a way to refer to "whatever the name of the 404 page is"...

      Admittedly, it's a bit of a stretch, but it seems worth asking, since obviously somewhere inside Convio CMS there's a DB table entry for "this is the 404 error page for this site".

    thanks again!

  • Alex Bernardin:

    Hey james,

      Helpful information, thank you! I understand the path variable, and it's extremely useful to know how Convio CMS is distinguishing between the requested URL and the served file.

      I'm thinking now about the code for the Convio wrapper - the code we're talking about does a simple pattern match to see if it's serving the 404 content, so that it will output Javascript that will put useful information into Google Analytics.  That's cool.  Now fastforward 6-12 months... the brilliant young coding gun who takes over my job when I win the lottery decides that 404.html is a lousy name for a page-not-found, so she renames that page (in Convio) 'not-found.html'.  And our clever wrapper code that was matching on '404.html' no longer matches the way that it's intended to.

      Is there any way to make the pattern matching code safe from that kind of change? That's what I meant by is there a way to refer to "whatever the name of the 404 page is"...

      Admittedly, it's a bit of a stretch, but it seems worth asking, since obviously somewhere inside Convio CMS there's a DB table entry for "this is the 404 error page for this site".

    thanks again!

    There's no way to do that yet unfortunately, but it is an excellent idea!

Categories