Tag Archives: url rewriting

Google Analytics & URL Rewriting Caveats

As the internet has matured and web sites have aged and expanded over the years, it has now become common place for web site owners to restructure their web sites to increase the sites accessibility and search engine effectiveness.

During the restructuring process, less savvy web masters reorganise their web sites without any concern for the impact it might have to their search engine rankings, referrals and user experience while more savvy web masters understand that cool URL’s don’t change. That isn’t to say that the content that was originally published against that URL must remain there, just that the URL exists so that anyone linking into it don’t receive missing document or HTTP 404 error.

When restructuring web sites, the savvy web master mentioned earlier requires a way to make an existing URL redirect to its new URL after the restructure. The two common methods to handle the redirection are:

  • It is perfectly acceptable to use a standard HTML web page with the tracking code installed and a meta refresh to redirect a user from the old to the new. This method does have the down side that all of the redirections for the web site are scattered throughout.
  • Another solution is offloading the redirection into a utility such as the Apache mod_rewrite module or the equivalent ISAPI_Rewrite for IIS. Using this method allows the web master to place all of the URL redirection in once place for easy management.

Under normal conditions such as option one above, where Google Analytics is installed on every web page within a site – it’s possible for the service to collect a complete click stream for the site. Google Analytics is also capable of handling standard HTTP redirects, so long as the tracking code is installed on both the referring and destination pages.

While it is convenient to use URL rewriting, there is a caveat which reduces the amount of information that Google Analytics can collect. The redirection will happen before any content is returned to the user, which means there is no opportunity for Google Analytics tracking code to fire. This results in Google Analytics reporting zero activity against the redirecting URL.