<?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>Josh Stauffer&#187; Tips</title>
	<atom:link href="http://www.joshstauffer.com/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joshstauffer.com</link>
	<description>WordPress, Genesis, &#38; Things I Care About</description>
	<lastBuildDate>Sun, 11 Dec 2011 01:08:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple Way to Track 404 Error Pages with Google Analytics</title>
		<link>http://www.joshstauffer.com/track-404s-with-google-analytics/</link>
		<comments>http://www.joshstauffer.com/track-404s-with-google-analytics/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 01:11:41 +0000</pubDate>
		<dc:creator>Josh Stauffer</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.joshstauffer.com/?p=135</guid>
		<description><![CDATA[Sometimes visitors to your site may receive a 404 Error or &#8220;Page Not Found&#8221;. This may happen when they click on a link that no longer exists or perhaps they typed the address incorrectly. If it&#8217;s a business website, a 404 Page Not Found could mean lost money but no matter the type of site, [...]


Related posts:<ol><li><a href='http://www.joshstauffer.com/how-to-install-google-analytics-on-wordpress/' rel='bookmark' title='Permanent Link: How to Install Google Analytics on WordPress'>How to Install Google Analytics on WordPress</a></li>
<li><a href='http://www.joshstauffer.com/wordpress-godaddy-permalinks-and-404s/' rel='bookmark' title='Permanent Link: WordPress, GoDaddy, Permalinks, and 404&#8242;s'>WordPress, GoDaddy, Permalinks, and 404&#8242;s</a></li>
<li><a href='http://www.joshstauffer.com/ways-to-use-document-write/' rel='bookmark' title='Permanent Link: JavaScript: 3 Ways to Use document.write'>JavaScript: 3 Ways to Use document.write</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.joshstauffer.com%2Ftrack-404s-with-google-analytics%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.joshstauffer.com%2Ftrack-404s-with-google-analytics%2F&amp;source=joshstauffer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes visitors to your site may receive a 404 Error or &#8220;Page Not Found&#8221;. This may happen when they click on a link that no longer exists or perhaps they typed the address incorrectly. If it&#8217;s a business website, a 404 Page Not Found could mean lost money but no matter the type of site, visitors hate 404 Errors. Unfortunately, they will typically leave your site instead of try to find the page they were intending to see.</p>
<p>With this understanding, tracking 404 Error Pages and correcting those errors is good practice and should help keep your visitors happy. Best of all, there&#8217;s a simple way to setup Google Analytics to <a href="http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&amp;answer=86927" target="_blank">track</a> those pesky 404s for us.</p>
<p>Since I&#8217;m a WordPress lover, the code below is specifically meant for WordPress websites although the code can be easily modified for any website platform you use.</p>
<h2>Here&#8217;s the code to use</h2>
<pre><code>&lt;script type=&quot;text/javascript&quot;&gt;

	var _gaq = _gaq || [];
	_gaq.push([&#39;_setAccount&#39;, &#39;UA-XXXXXXX-X&#39;]);
	&lt;?php if ( is_404() ) { ?&gt;
	_gaq.push([&#39;_trackPageview&#39;, &#39;/404.html?page=&#39; + document.location.pathname + document.location.search + &#39;&amp;from=&#39; + document.referrer]);
	&lt;?php } else { ?&gt;
	_gaq.push([&#39;_trackPageview&#39;]);
	&lt;?php } ?&gt;

	(function() {
		var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;
		ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;https://ssl&#39; : &#39;http://www&#39;) + &#39;.google-analytics.com/ga.js&#39;;
		var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);
	})();

&lt;/script&gt;</code></pre>
<p>Be sure to replace <tt>UA-XXXXXXX-X</tt> with your Analytics Web Property ID.</p>
<p>Basically what&#8217;s happening above is we use the WordPress <a href="http://codex.wordpress.org/Function_Reference/is_404" target="_blank"><tt>is_404()</tt></a> conditional tag to check if there&#8217;s a 404 error. If an 404 Page Not Found error occurs, this code is output:</p>
<pre><code>_gaq.push([&#39;_trackPageview&#39;, &#39;/404.html?page=&#39; + document.location.pathname + document.location.search + &#39;&amp;from=&#39; + document.referrer]);</code></pre>
<p>And for all other pages, this code is output:</p>
<pre><code>_gaq.push([&#39;_trackPageview&#39;]);</code></pre>
<p>And it&#8217;s really as simple as that. <img src='http://www.joshstauffer.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://www.joshstauffer.com/how-to-install-google-analytics-on-wordpress/' rel='bookmark' title='Permanent Link: How to Install Google Analytics on WordPress'>How to Install Google Analytics on WordPress</a></li>
<li><a href='http://www.joshstauffer.com/wordpress-godaddy-permalinks-and-404s/' rel='bookmark' title='Permanent Link: WordPress, GoDaddy, Permalinks, and 404&#8242;s'>WordPress, GoDaddy, Permalinks, and 404&#8242;s</a></li>
<li><a href='http://www.joshstauffer.com/ways-to-use-document-write/' rel='bookmark' title='Permanent Link: JavaScript: 3 Ways to Use document.write'>JavaScript: 3 Ways to Use document.write</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.joshstauffer.com/track-404s-with-google-analytics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

