<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Development Advice and Tips &#187; Google Analytics</title>
	<atom:link href="http://blog.smartlogicsolutions.com/category/google-analytics/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>SmartLogic Solutions Blog</description>
	<lastBuildDate>Fri, 14 Jun 2013 14:26:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Rack::Rewrite + Google Analytics Makes Site Transitions Seamless</title>
		<link>http://blog.smartlogicsolutions.com/2009/11/24/rack-rewrite-google-analytics-makes-site-transitions-seamless/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/11/24/rack-rewrite-google-analytics-makes-site-transitions-seamless/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 14:20:20 +0000</pubDate>
		<dc:creator>John Trupiano</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Rack]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[rack-rewrite]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=718</guid>
		<description><![CDATA[<p>At SmartLogic we recently rebuilt our website in rails. The previous version was a MediaWiki installation with a ton of content that had garnered a decent bit of Google juice that we did not want to lose. By setting up 301 permanent redirects for the old URL&#8217;s, we can hold onto that juice. Enter Rack::Rewrite. [...]<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2013/02/20/ios-development/"     class="crp_title">iOS Development: How to Create a Lightbox Effect</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/08/30/nicks-highlights-from-lone-star-ruby-conf/"     class="crp_title">Nick&#8217;s Highlights from Lone Star Ruby Conf</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/06/22/railsconf-bohconf-2010-a-retrospective/"     class="crp_title">BohConf 2010: A Retrospective</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/04/30/22-links-from-railsconf-2013-day-1/"     class="crp_title">22 Links From RailsConf 2013 Day 1</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div></p><p>The post <a href="http://blog.smartlogicsolutions.com/2009/11/24/rack-rewrite-google-analytics-makes-site-transitions-seamless/">Rack::Rewrite + Google Analytics Makes Site Transitions Seamless</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>At SmartLogic we recently rebuilt our <a href="http://www.smartlogicsolutions.com">website</a> in rails.  The previous version was a MediaWiki installation with a ton of content that had garnered a decent bit of Google juice that we did not want to lose.  By setting up 301 permanent redirects for the old URL&#8217;s, we can hold onto that juice.</p>
<p><span id="more-718"></span></p>
<div id="attachment_762" class="wp-caption alignright" style="width: 160px"><a href="http://blog.smartlogicsolutions.com/wp-content/uploads/2009/11/Picture-2.png"><img src="http://blog.smartlogicsolutions.com/wp-content/uploads/2009/11/Picture-2-150x150.png" alt="Google Analytics Navigation" title="Google Analytics Navigation" width="150" height="150" class="size-thumbnail wp-image-762" /></a><p class="wp-caption-text">Google Analytics Navigation</p></div>
<p>Enter Rack::Rewrite.  <a href="http://github.com/jtrupiano/rack-rewrite">Rack::Rewrite</a> is a <a href="http://rack.rubyforge.org/">Rack</a> middleware for defining and applying rewrite rules.  Though it&#8217;s not a full replacement for <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">Apache&#8217;s mod_rewrite</a>, a great deal of rules I&#8217;ve previously written in Apache config files can be replaced by Rack::Rewrite.  Run <code>gem install rack-rewrite</code> to install the gem.</p>
<p>In order to determine which URL&#8217;s were most important to issue 301&#8242;s for, we turned to Google Analytics.  By reviewing the most popular landing pages of the past two months from our site, we were able to methodically write our redirect rules.</p>
<div id="attachment_766" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.smartlogicsolutions.com/wp-content/uploads/2009/11/Picture-33.png"><img src="http://blog.smartlogicsolutions.com/wp-content/uploads/2009/11/Picture-33-300x291.png" alt="Google Analytics | Top Landing Pages" title="Google Analytics | Top Landing Pages" width="300" height="291" class="size-medium wp-image-766" /></a><p class="wp-caption-text">Google Analytics | Top Landing Pages</p></div>
<p>Here is a subset of the associated Rack::Rewrite rules.</p>
<pre class="wp-code-highlight prettyprint">
  config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do        
    # original wiki smartlogicsolutions.com website
    r301 &#039;/wiki/Main_Page&#039;, &#039;/&#039;
    r301 &#039;/wiki/John_Trupiano&#039;, &#039;/john&#039;
    r301 %r{^/wiki/(Charity|Charities|Local_Connection)$}, &#039;/gratis-work-and-charities&#039;
    r301 &#039;/wiki/Category:Portfolio&#039;, &#039;/portfolio&#039;
    r301 &#039;/wiki/ExxonMobil_-_Brand_Asset_Center&#039;, &#039;/portfolio/exxonmobil-brand-asset-center&#039;
    r301 &#039;/wiki/In_the_News&#039;, &#039;/in-the-news&#039;
    r301 &#039;/wiki/Getting_to_our_Office&#039;, &#039;/driving-directions&#039;
    r301 &#039;/wiki/Category:Employees&#039;, &#039;/our-team&#039;
    r301 &#039;/wiki/SimNet_for_Office_2007&#039;, &#039;/portfolio/simnet-for-office-2007-and-vista&#039;
    r301 &#039;/wiki/VNC_Collaboration_Application&#039;, &#039;/portfolio/shared-desktop&#039;
    r301 &#039;/wiki/Contact_Information&#039;, &#039;/contact-us&#039;
  end
</pre>
<p>This scheme is great for landing pages, but what if we had querystring information that we wanted to keep around?  This is common for tracking codes &#8212; many marketing platforms generate URL&#8217;s that embed data in the querystring for recording and tracking purposes.  We can leverage the following trick to maintain the querystring across a rewrite.</p>
<pre class="wp-code-highlight prettyprint">
  r301 %r{^/wiki/Main_Page(\?.*)?$}, &#039;/$1&#039; 
</pre>
<p>Note the following:</p>
<ul>
<li>We are conditionally matching a querystring so that the rule continues to match in the absence of a querystring. </li>
<li>We are leveraging substitution patterns to reconstitute the querystring in the rewritten URL.
</ul>
<p>Many more great use cases for Rack::Rewrite are covered in the project&#8217;s <a href="http://github.com/jtrupiano/rack-rewrite">README</a>.</p>
<div class="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2013/02/20/ios-development/"     class="crp_title">iOS Development: How to Create a Lightbox Effect</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/08/30/nicks-highlights-from-lone-star-ruby-conf/"     class="crp_title">Nick&#8217;s Highlights from Lone Star Ruby Conf</a></li><li><a href="http://blog.smartlogicsolutions.com/2012/07/12/curlin-for-docs/"     class="crp_title">cURLin’ for Docs</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/06/22/railsconf-bohconf-2010-a-retrospective/"     class="crp_title">BohConf 2010: A Retrospective</a></li><li><a href="http://blog.smartlogicsolutions.com/2013/04/30/22-links-from-railsconf-2013-day-1/"     class="crp_title">22 Links From RailsConf 2013 Day 1</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/" rel="nofollow">Contextual Related Posts</a></li></ul></div><p>The post <a href="http://blog.smartlogicsolutions.com/2009/11/24/rack-rewrite-google-analytics-makes-site-transitions-seamless/">Rack::Rewrite + Google Analytics Makes Site Transitions Seamless</a> appeared first on <a href="http://blog.smartlogicsolutions.com">Web Development Advice and Tips</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/11/24/rack-rewrite-google-analytics-makes-site-transitions-seamless/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
