<?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>Sarah DeAtley &#187; javascript</title>
	<atom:link href="http://www.sarahdeatley.com/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sarahdeatley.com</link>
	<description>information + analysis + design</description>
	<lastBuildDate>Mon, 17 May 2010 06:29:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Having issues with event tracking in Google Analytics? Read on&#8230;</title>
		<link>http://www.sarahdeatley.com/blog/2009/07/29/having-issues-with-event-tracking-in-google-analytics-read-on/</link>
		<comments>http://www.sarahdeatley.com/blog/2009/07/29/having-issues-with-event-tracking-in-google-analytics-read-on/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 05:40:48 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Analytics]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[burke]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[issues]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[problems]]></category>
		<category><![CDATA[The Grok]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.sarahdeatley.com/blog/?p=333</guid>
		<description><![CDATA[
			
				
			
		
Note: feel free to ping me or leave a comment if you are having major issues!
Yesterday the event tracking on a site was not working, and someone thought it might be that I had missed a call to the ga.js file or some extra Javascript. My first thought was &#8220;This is why I hate Javascript.&#8221; [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-bottom: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.sarahdeatley.com%2Fblog%2F2009%2F07%2F29%2Fhaving-issues-with-event-tracking-in-google-analytics-read-on%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.sarahdeatley.com%2Fblog%2F2009%2F07%2F29%2Fhaving-issues-with-event-tracking-in-google-analytics-read-on%2F&amp;source=sarahd23&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><em><strong>Note: feel free to ping me or leave a comment if you are having major issues!</strong></em></p>
<p>Yesterday the <a href="http://www.sarahdeatley.com/blog/2009/07/07/event-tracking-in-google-analytics/" target="_self">event tracking </a>on a site was not working, and someone thought it might be that I had missed a call to the ga.js file or some extra Javascript. My first thought was &#8220;This is why I hate Javascript.&#8221; That thought recurred throughout my investigation process, but I decided to save some people time and effort by posting a few things you could check before giving up and crying. My particular example was an onClick event, but the same things could apply to other situations.</p>
<ol>
<li><strong>Check the JavaScript call<em>. </em></strong>So you must understand that Javascript (which I shall now write as JS) can be the best and worst scripting language. Very powerful and can do cool things like animation (and your analytics tracking), but also a pain in that you must be very careful with syntax and punctuation. One easy way to see if your JS is creating errors is by installing the <a href="https://addons.mozilla.org/en-US/firefox/addon/60" target="_blank">Web Developer&#8217;s Toolbar </a>in Firefox, it will show you when there are JS errors and a myriad of other useful things.<br />
<blockquote style="font-size: 15px"><p><em>Example</em>: <strong>onclick=&#8221;pageTracker._trackEvent(&#8220;Foo&#8221;,&#8221;Bar&#8221;,&#8221;JS&#8221;);&#8221;</strong> This will be wrong because you have double quotation marks instead of apostrophes within the parentheses. So the page will read it as &#8220;pageTracker.trackEvent(&#8221; which will not do anything. Fix it like this: <strong>onclick=&#8221;pageTracker._trackEvent(&#8216;Foo&#8217;,'Bar&#8217;,'JS&#8217;);&#8221;</strong>.</p></blockquote>
</li>
<li><strong>Is the variable actually pageTracker? </strong>In most cases, if you&#8217;re not changing the Google Analytics code that is on every page, it should be pageTracker. If the variable is named anything else, like movieTracker or pageCounter, then you need to fix the call in the onClick and change it to: onclick=&#8221;movieTracker._trackEvent(&#8230;);&#8221; This is the part of the code you want to pay attention to:<br />
<blockquote style="font-size: 15px"><p>try {<br />
<em>var <strong>pageTracker</strong></em> = _gat._getTracker(&#8220;UA-xxxxxx-x&#8221;);<br />
<strong><em>pageTracker</em></strong>._trackPageview();<br />
} catch(err) {}</p></blockquote>
</li>
<li><strong>Where your code at?</strong> This ended up being my problem. People recommend that the GA code should be inserted at the footer of the page to not slow down the loading time of a page. The catch is, the JS file/definition of the variable pageTracker may need to be at the top of the page for _trackEvent to do its thing. If you try moving the code with the ga.js file to the head of the page, it should help. Or it helped me anyway.</li>
</ol>
<p>As much as I hate debugging JS, I think it has really helped me to have knowledge of how it works, so if this is all kinds of confusing, try working through the <a href="http://http://www.w3schools.com/JS/default.asp" target="_blank">W3C tutorials</a>.</p>
<h3>Misc.</h3>
<p><a href="http://www.grokdotcom.com/2009/07/29/turning-web-analytics-into-nonprofit-success/" target="_blank">The Grok delivers</a>!! I was tweeting with <a href="http://twitter.com/thegrok" target="_blank">@TheGrok</a> and I asked if there was any way he could post about web analytics for non-profits. Brendan Regan wrote an awesomely helpful post about it. I will probably comment more about it later, but still, very cool.</p>
<p>And for those who use Twitter, #wa is being deprecated in favor of #measure. See Web Analytics Demystified for an <a href="http://blog.webanalyticsdemystified.com/weblog/2009/07/measure-is-the-new-wa-in-twitter.html" target="_blank">explanation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sarahdeatley.com/blog/2009/07/29/having-issues-with-event-tracking-in-google-analytics-read-on/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Event Tracking in Google Analytics</title>
		<link>http://www.sarahdeatley.com/blog/2009/07/07/event-tracking-in-google-analytics/</link>
		<comments>http://www.sarahdeatley.com/blog/2009/07/07/event-tracking-in-google-analytics/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 04:25:16 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[Web Analytics]]></category>
		<category><![CDATA[event tracking]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[soccer]]></category>
		<category><![CDATA[web analytics]]></category>

		<guid isPermaLink="false">http://www.sarahdeatley.com/blog/?p=190</guid>
		<description><![CDATA[
			
				
			
		
This is my secret shame, but until today I never tried using event tracking.  Probably because I assumed (until I was informed today) that event tracking and page tagging involved writing complex JavaScript, when in fact all you&#8217;re doing is calling a function and adding variables.  I should have guessed that Google Analytics (and other [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-bottom: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.sarahdeatley.com%2Fblog%2F2009%2F07%2F07%2Fevent-tracking-in-google-analytics%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.sarahdeatley.com%2Fblog%2F2009%2F07%2F07%2Fevent-tracking-in-google-analytics%2F&amp;source=sarahd23&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This is my secret shame, but until today I never tried using event tracking.  Probably because I assumed (until I was informed today) that event tracking and page tagging involved writing complex JavaScript, when in fact all you&#8217;re doing is calling a function and adding variables.  I should have guessed that Google Analytics (and other software) would try to make this a painless process, but JavaScript still intimidates me sometimes.</p>
<p>I tested it out today by inserting events into the tabs in my <a href="http://www.sarahdeatley.com/portfolio.php" target="_self">portfolio</a> pages in a simple onclick call:</p>
<blockquote><p>&lt;a href=&#8221;#&#8221; onClick=&#8221;pageTracker._trackEvent(&#8216;Tabs&#8217;, &#8216;Click&#8217;, &#8216;Project 1&#8242;);&#8221;&gt;</p></blockquote>
<p>I won&#8217;t get any data until at least tomorrow (assuming anyone clicks on it, but I clicked on all of them to make sure it works).  Basically this code can be put into any section within your code that you want to track, such as downloads, video plays, clickthroughs, etc. Its a really powerful capability that I wish I would have tried out earlier but I think I&#8217;ll be using it plenty from here on out now that I see how easy it is.</p>
<p>All I had to worry about was the things inside the parentheses which translate to: &#8216;<em>category&#8217;, &#8216;action&#8217;,'label&#8217;, &#8216;value</em>&#8216;.  The last 2 things are optional, but what is nice is that you can name these in almost any way you want so that they are descriptive and unique.  You can also keep categories and actions the same in different events if you want to associate like categories and actions.</p>
<div id="attachment_197" class="wp-caption aligncenter" style="width: 494px"><a href="http://www.sarahdeatley.com/blog/wp-content/uploads/2009/07/event_tracking_graph.png" rel="lightbox[190]"><img class="size-full wp-image-197" title="event tracking graph" src="http://www.sarahdeatley.com/blog/wp-content/uploads/2009/07/event_tracking_graph.png" alt="Most depressing graph ever" width="484" height="146" /></a><p class="wp-caption-text">Most depressing graph ever</p></div>
<p>Now I feel especially empowered to segment data further and drill down into the data of sites and pages to see what people are doing on the page for specific sections and dynamic elements. Web analytics is nerdy fun for me, don&#8217;t judge.</p>
<p>Aaaand&#8230;just as I quit all my soccer teams for the summer, I decided to play with the ZAAZ team. Oops.  Today I got to play some with Web Trends and Omniture and I&#8217;m looking forward to learning more about the cool things they can do. Though apparently Google Analytics is catching up quickly.</p>
<p>I also wonder if I will be able to take the Microsoft Connector to work even though I&#8217;m part-time there. I hope so. I&#8217;m always jealous of their wi-fi and clean looking shuttles.</p>
<p>UPDATE: Huzzah! It worked.</p>
<div id="attachment_203" class="wp-caption aligncenter" style="width: 353px"><a href="http://www.sarahdeatley.com/blog/wp-content/uploads/2009/07/event_tracking_update.png" rel="lightbox[190]"><img class="size-full wp-image-203" title="Event tracking update" src="http://www.sarahdeatley.com/blog/wp-content/uploads/2009/07/event_tracking_update.png" alt="A less depressing table" width="343" height="159" /></a><p class="wp-caption-text">A less depressing table</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sarahdeatley.com/blog/2009/07/07/event-tracking-in-google-analytics/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>God reads my blog</title>
		<link>http://www.sarahdeatley.com/blog/2009/06/23/god-reads-my-blog/</link>
		<comments>http://www.sarahdeatley.com/blog/2009/06/23/god-reads-my-blog/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 18:11:58 +0000</pubDate>
		<dc:creator>Sarah</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[ixd]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[reading]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.sarahdeatley.com/blog/?p=44</guid>
		<description><![CDATA[
			
				
			
		
&#8230;because it is sunny again in Seattle! w00t! I am now done updating the site for the moment. I condensed the nonsense on here thanks to the informal usability advice of &#8220;Richard Branson.&#8221; Today is my last day off this week so I would plan on tanning, but there are definitely a lot of construction [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-bottom: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.sarahdeatley.com%2Fblog%2F2009%2F06%2F23%2Fgod-reads-my-blog%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.sarahdeatley.com%2Fblog%2F2009%2F06%2F23%2Fgod-reads-my-blog%2F&amp;source=sarahd23&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>&#8230;because it is <a href="http://www.sarahdeatley.com/blog/?p=36" target="_self">sunny again in Seattle</a>! w00t! I am now done updating the site for the moment. I condensed the nonsense on here thanks to the informal usability advice of &#8220;Richard Branson.&#8221; Today is my last day off this week so I would plan on tanning, but there are definitely a lot of construction workers that can see me. So maybe not so much.</p>
<p>And borrowed from the amazing D.A. Clements, Information School lecturer and mentor extraordinaire,  5 books to read on web design/interaction design from the iSchool webmaster:</p>
<blockquote>
<ul>
<li>BIll Buxton. <em>Sketching User Experience</em></li>
<li>DK Van Duyne, JA Landry, JI Hong. <em>Design of Sites</em></li>
<li>Jenifer Tidwell. <em>Designing Interfaces</em></li>
<li>Dan Brown (not the Da Vinci Code guy). <em>Communicating Design</em></li>
<li>Andrew Dupont. <em>Practical Prototyping and Scriptaculous</em></li>
</ul>
</blockquote>
<p>I&#8217;ve read parts of the Bill Buxton and I think Tidwell books, but not the others.  Now I have time to read this stuff, but I&#8217;m still finishing the <a href="http://www.amazon.com/Information-Architecture-World-Wide-Web/dp/0596000359" target="_blank">Polar Bear book</a>. I&#8217;ve skimmed it before, but I&#8217;m trying to pay attention this time. I didn&#8217;t realize Scriptaculous was supposed to be any better for prototyping than another Javascript library, but the same things can probably be applied to other libraries.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sarahdeatley.com/blog/2009/06/23/god-reads-my-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
