<?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>Mike Brittain &#187; xhtml</title>
	<atom:link href="http://www.mikebrittain.com/blog/tag/xhtml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikebrittain.com/blog</link>
	<description>Internet, mobile applications, skiing, snowboarding, food... you know, whatever comes to mind.</description>
	<lastBuildDate>Sun, 22 Jan 2012 16:24:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Why Google Analytics (&#8220;ga.js&#8221;) Doesn&#8217;t Work with XHTML</title>
		<link>http://www.mikebrittain.com/blog/2008/09/13/google-analytics-and-xhtml/</link>
		<comments>http://www.mikebrittain.com/blog/2008/09/13/google-analytics-and-xhtml/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 18:44:27 +0000</pubDate>
		<dc:creator>Mike Brittain</dc:creator>
				<category><![CDATA[WWW]]></category>
		<category><![CDATA[googleanalytics]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[tracking]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.mikebrittain.com/blog/?p=182</guid>
		<description><![CDATA[Finding a small issue with Google Analytics&#8217; tracking code when served on pages with the application/xhtml+xml mime-type&#8230; It doesn&#8217;t work. The issue is that the code checks the current HTTP protocol for the page, whether it is served as SSL or not.  If it is, the tracking code is served from a secure server to [...]]]></description>
			<content:encoded><![CDATA[<p>Finding a small issue with Google Analytics&#8217; tracking code when served on pages with the application/xhtml+xml mime-type&#8230; It doesn&#8217;t work.</p>
<p>The issue is that the code checks the current HTTP protocol for the page, whether it is served as SSL or not.  If it is, the tracking code is served from a secure server to prevent your browser from complaining.  The actual tracking code is loaded using a script that uses a document.write() operation to add the script tag to your page.  This is illegal on pages served as XML, because the browser (at least Firefox) is designed to restrict JavaScript from inserting markup during render time.</p>
<p>This probably affects only the &#8220;latest&#8221; tracking code, ga.js, and not the legacy code, urchin.js.</p>
<p>The fix is actually pretty easy, despite the fact that I couldn&#8217;t find any official documentation about it from Google.  Take a look at the legacy code for inserting urchin.js on your page.  It uses a normal script tag, instead of using document.write() to insert the tag &#8212; which is legal.</p>
<p>Now look at the JS code used to insert ga.js.  Assuming you&#8217;re not serving an SSL site, you can replace the document.write() with a static script tag.  Something like the one below:</p>
<p><code>&lt;script src="http://www.google-analytics.com/ga.js" type="text/javascript"&gt;&lt;/script&gt;</code></p>
<p>If you <em>are</em> using SSL on your site, along with the application/xhtml+xml mime-type, then it&#8217;s up to you to deal with switching the hostname and protocol in the URL in the appropriate pages.</p>
<p>You <strong>should not</strong> make this change to the tracking code unless you need to (i.e. you&#8217;re serving XHTML and tracking pixels are not firing properly).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikebrittain.com/blog/2008/09/13/google-analytics-and-xhtml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

