<?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>Work, Web, Play &#187; Web Analytics</title>
	<atom:link href="http://workwebplay.com/category/web-analytics/feed/" rel="self" type="application/rss+xml" />
	<link>http://workwebplay.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 16 Aug 2010 02:58:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Clean up your event tracking with jQuery</title>
		<link>http://workwebplay.com/2010/08/15/event-tracking-jquery/</link>
		<comments>http://workwebplay.com/2010/08/15/event-tracking-jquery/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 02:54:51 +0000</pubDate>
		<dc:creator>Colin Temple</dc:creator>
				<category><![CDATA[Web Analytics]]></category>
		<category><![CDATA[event tracking]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[web analysis]]></category>

		<guid isPermaLink="false">http://workwebplay.com/?p=113</guid>
		<description><![CDATA[In my last post, I went through the basics of setting up Google Analytics event tracking. In doing so, I showed how to create click events using the onclick event for things like links and images. However, littering your code with onclick events can be a bit messy, and if you&#8217;re anything like me, you [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post, I went through the basics of setting up <a href="http://workwebplay.com/2010/08/06/google-analytics-event-tracking/">Google Analytics event tracking</a>. In doing so, I showed how to create click events using the <code>onclick</code> event for things like links and images. However, littering your code with <code>onclick</code> events can be a bit messy, and if you&#8217;re anything like me, you prefer your code to be a little cleaner.<span id="more-113"></span></p>
<p>Enter jQuery. If you&#8217;re a web developer and you haven&#8217;t taken <a href="http://jquery.com/">jQuery</a> out for a spin yet, then you need to <a href="http://www.amazon.com/gp/product/0980576857?ie=UTF8&amp;tag=sweetbuysnet-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0980576857">do a little reading</a>. Among jQuery&#8217;s many features is its ability to easily select any element on an HTML page from your JavaScript code, and then manipulate or watch that element.</p>
<p>Watch it like a hawk.</p>
<p>The advantage for event tracking? You can neatly organize your event tracking codes, putting them all in one place &#8212; in your header or an external JavaScript file &#8212; rather than littered throughout your code. It makes tracking your tracking easy, and it can even speed up the deployment of powerful event tracking codes.</p>
<p>Let&#8217;s look at a quick example. Suppose that I have a link on my site, and every time that link is clicked, I&#8217;m tracking it as an event in Google Analytics. My code may look something like this:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>&lt;a  href="http://www.google.ca/" onclick="_gaq.push(['_trackEvent', 'External Links', 'Click', 'google.ca']);"&gt;Google.ca&lt;/a&gt;</code></div>
<p><strong>Clean it up with jQuery</strong><br />
The details of the link aren&#8217;t important, but essentially I&#8217;m tracking clicks on external links, in this case one that goes out to Google Canada. Here, I&#8217;m using the <code>onclick</code> attribute to assign the action to the link. What jQuery lets me do is move that out of the link. I can replace the JavaScript with an ID in my link:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>&lt;a  href="http://www.google.ca/" id="GoogleOut"&gt;Google.ca&lt;/a&gt;</code></div>
<p>And then move the tracking code to a <code>&lt;script&gt;</code> area in my header:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code><br />
&lt;script type="text/javascript"&gt;<br />
$(document).ready(function(){<br />
$('#GoogleOut').click(function(){<br />
_gaq.push(['_trackEvent', 'External Links', 'Click', 'google.ca']);<br />
});<br />
});<br />
&lt;/script&gt;</code></div>
<p>What we&#8217;ve done is created a function that will execute on <code>$(document).ready</code>, which is a jQuery handler for the moment that the DOM &#8212; the set of objects on the page &#8212; is fully loaded and ready for manipulation by JavaScript. We then create another function that is bound to the <code>click</code> event of the link we created, which we reference by its ID, <code>GoogleOut</code>. The selector style is the same as CSS: we use the &#8216;#&#8217; symbol for IDs, and the dot &#8216;.&#8217; for classes.</p>
<p><strong>One code for multiple events</strong><br />
Now, we have the advantage of moving all of our event tracking code to this same <code>$(document).ready</code> function, listing them one after another. That helps with the managability, but we still have to set up IDs for each link. What if we have several external links on a page? It would be as tedious to give them each an ID as it would to manage all of the onclicks.</p>
<p>For this, we can use jQuery&#8217;s ability to not only select multiple elements on a page, but gain access to individual elements. First, let&#8217;s change our link code. Rather than give it an unique ID, let&#8217;s give it a class name, &#8220;external&#8221;, which can be used for all of the external links on our site.</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>&lt;a  href="http://www.google.ca/" class="external"&gt;Google.ca&lt;/a&gt;</code></div>
<p>Next, let&#8217;s modify our code to select all external links, instead of just our Google one.</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code><br />
&lt;script type="text/javascript"&gt;<br />
$(document).ready(function(){<br />
$('a.external').click(function(){<br />
_gaq.push(['_trackEvent', 'External Links', 'Click', $(this).attr('src')]);<br />
});<br />
});<br />
&lt;/script&gt;</code></div>
<p>You&#8217;ll notice that not only did I change the selector to <code>'a.external'</code>, but I changed the last parameter of the Google Analytics event tracking code to <code>$(this).attr('href')</code>. In my original code, I had written in &#8216;google.ca&#8217; so that we would see in the Google Analytics reports that the click out was on the link to Google, specifically. Now, I want to track all external links on my site, not just to Google.</p>
<p>In this case, I&#8217;ve used jQuery code to select the <code>href</code> attribute (using the <code>.attr()</code> method) of whatever link was clicked (which we specify by <code>$(this)</code>). The <code>href</code> attribute, of course, contains the URL of the link. So, not only does this code now track my link to Google, but it will track each and every external link on my website, as long as I tag them with the <code>external</code> class name, and tell me which external links have been clicked.</p>
<p>By now the power of jQuery for event tracking should be clear &#8212; not only can you use it to clean up your code, but you can track multiple events with a single line of code. You may even be able to add event tracking to large sites without changing much more than the header code. jQuery selectors will allow you to grab existing elements on your web pages without dabbling in their individual code.</p>
<p>If you&#8217;d like to learn jQuery, I highly recommend Sitepoint&#8217;s <a href="http://www.amazon.com/gp/product/0980576857?ie=UTF8&amp;tag=sweetbuysnet-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0980576857">jQuery: Novice to Ninja</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=sweetbuysnet-20&amp;l=as2&amp;o=1&amp;a=0980576857" border="0" alt="" width="1" height="1" />. I have a copy, and it&#8217;s a great resource, both for those who want to dip a toe into the jQuery waters and for those who want to expand their skills with jQuery and JavaScript in general.</p>
<p>It&#8217;s powerful stuff for neat, efficient coding of event tracking. The example I used, specifically, can help you determine which external links on your site are useful, and which aren&#8217;t. For example, using this data a <a href="http://www.napkyn.com/analyst-program/">web analyst</a> could tell you whether the outbound links on your site are helping to complement your site or lend credibility to interested buyers &#8212; or if they&#8217;re just sending visitors away for good.</p>
]]></content:encoded>
			<wfw:commentRss>http://workwebplay.com/2010/08/15/event-tracking-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event Tracking with Google Analytics</title>
		<link>http://workwebplay.com/2010/08/06/google-analytics-event-tracking/</link>
		<comments>http://workwebplay.com/2010/08/06/google-analytics-event-tracking/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 20:27:13 +0000</pubDate>
		<dc:creator>Colin Temple</dc:creator>
				<category><![CDATA[Web Analytics]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[event tracking]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://workwebplay.com/?p=111</guid>
		<description><![CDATA[It&#8217;s been quite a while since the Google Analytics team introduced event tracking, but many people I talk to don&#8217;t understand it. In some cases, they don&#8217;t even know it&#8217;s there. Nevertheless, event tracking is one of the most useful tools for getting data into Google Analytics and it opens up analysis on many things [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been quite a while since the Google Analytics team introduced event tracking, but many people I talk to don&#8217;t understand it. In some cases, they don&#8217;t even know it&#8217;s there. Nevertheless, <strong>event tracking</strong> is one of the most useful tools for getting data into Google Analytics and it opens up analysis on many things we just couldn&#8217;t see before.<span id="more-111"></span></p>
<p><strong>What&#8217;s Event Tracking?</strong></p>
<p>Traditionally, web metrics were entirely based on page views. We look at what pages visitors see, and in what order they see them. But that&#8217;s not how the web works anymore&#8230; things are not just page-by-page. You can search a Google map and then move around or drag your location pins without reloading the page. You can post your Facebook status updates and see new tweets come in on Twitter without reloading. You can watch, pause and rewind videos, without reloading. JavaScript, which enables this interaction, is more important than ever to using the web.</p>
<p>Event tracking allows you to gather data when these things happen. Older techniques for tracking things like video plays involved forging URLs &#8212; using a snippet of code that would &#8220;pretend&#8221; that a page was loaded so that we could track the event. With proper event tracking, we no longer need to view things as URLs. We can track events as what they are &#8212; non-pageview events.</p>
<p><strong>Getting Started</strong></p>
<p>Here&#8217;s what you need to know to get started using events in Google Analytics:</p>
<p>First, Google has set up several fields for each event, for the purpose of categorizing them. Events are grouped by Category, Action, Label and Value. Let&#8217;s look at how they play together.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-141" title="Google Analytics Event Groupings" src="http://workwebplay.com/wp-content/uploads/2010/08/Analytics-Event-Groupings.png" alt="" width="667" height="310" /></p>
<p>The above diagram shows four events that are grouped into two categories. The events are represented by the coloured boxes.</p>
<p>Let&#8217;s consider the first category of events, &#8220;Videos&#8221;. This event category will relate to actions that are taken on videos throughout the website. In other words, all events that take place with videos on the site, including videos played, paused, downloaded or shared, will be tracked in this one category.</p>
<p>The next level down is the Action. As the name suggests, actions are the specific thing that was done by the user to trigger this event. In the case of these videos, we have an action for &#8220;Play&#8221; and an action for &#8220;Pause&#8221;.  We can find out pure metrics for actions, such as how many videos were played by a specific segment within a time frame, or we can use them to group specific events and drill down by event type.</p>
<p>On the next level is the label. For our videos, we&#8217;re using the label to indicate which video an action was performed on. For instance, the first event in the diagram is a &#8220;Play&#8221; action labeled &#8220;Training Video&#8221;. Now I know specifically which video was played. The next action has the same label, but is of the &#8220;Pause&#8221; type &#8212; meaning that the training video was paused, triggering this event.</p>
<p>The last number is &#8220;value&#8221;. Value is an integer field which, in the case of my videos, is left blank. Values are used to provide specific counts that are useful to the event. For instance, if the event is the removal of an item from a shopping cart, I may use the &#8220;Value&#8221; field to indicate the dollar amount of the item removed. Then, I can know the total value of all products that were removed from carts prior to purchases.</p>
<p>Our next event category does make use of the values. This category is called &#8220;Contact Form&#8221;, and is used on a website for events related to that form. Our first event&#8217;s action is a form error, which means a failure to send the form because something went wrong.  The label is used to indicate the type of form error, in this case, an &#8220;Invalid Email&#8221;. We&#8217;ve also included a value, &#8220;3&#8243;. That value is, for this event, the number of errors that the specific visitor has encountered so far. Thus, we know that this invalid email was the third error encountered by the user.</p>
<p>The last event is also for the contact form, in this case tracking a successful submission of the form (the Action), and the type of request that was sent (the Label).</p>
<p>Now, you don&#8217;t necessarily need to use Categories, Actions, Labels and Values in the exact way that I&#8217;ve laid out. What matters is that you formulate a method for tracking events and stick to it.</p>
<p><strong>The Code: Tracking an Event</strong></p>
<p>To actually implement the tracking on your site, you&#8217;ll need to add a little bit of JavaScript code. The code I present here uses the asynchronous method of tracking. This is a new method of tracking that Google recently deployed as its standard tracking method. You don&#8217;t <em>have</em> to use the asynch. method to use event tracking, but it may be a good time to upgrade anyways.</p>
<p>You can tell if you have the asynch method by looking at the Google Analytics tracking code on your site. If it begins with the following:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>var _gaq = _gaq || [];</code></div>
<p>Then you&#8217;re ready to go. If not, just log into your Google Analytics account, re-copy your tracking code and update your site.</p>
<p>Now, you just need to add tracking codes to the events on your site. Suppose, for example, that you have an image gallery on your site, and that clicking on an image enlarges it. Your code for a particular image may look something like this:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>&lt;img src="foo.jpg" alt="" /&gt;</code></div>
<p>Let&#8217;s say you want to track how many people click on this image. You&#8217;ll want to add the tracking code to the <strong>onclick</strong> event for that image. Onclick is a JavaScript event that allows you to execute code when someone clicks on something. To do so, add this code.</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>&lt;img src="foo.jpg" alt="" onclick="_gaq.push(['_trackEvent', 'Images', 'Enlarged', 'foo.jpg']);" /&gt;</code></div>
<p>Let&#8217;s examine the code for that event more closely. The code to track an event in Google Analytics is as follows:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>_gaq.push(['_trackEvent', 'CATEGORY', 'ACTION', 'LABEL', 'VALUE']);</code></div>
<p>For our event, we coded it as follows:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>_gaq.push(['_trackEvent', 'Images', 'Enlarged', 'foo.jpg']);</code></div>
<p>The first field in the _gaq.push() function is called &#8216;_trackEvent&#8217;. What it does is obvious &#8212; it tells Google Analytics that we want to track an event. The next field is the category. We set it to &#8220;Images&#8221;, because that&#8217;s what we&#8217;re dealing with. The action is the next field, which I set to &#8220;Enlarged&#8221; to tell us that someone clicked on an image to enlarge it. The last field is for the label, which I set to the filename of the image that is being enlarged, so that I can track how many times each image is enlarged.</p>
<p>Notice how I didn&#8217;t add a fifth field for the value. I&#8217;m not tracking a value here at all, so I can omit that bit. In fact, you can also omit labels if you don&#8217;t need them.</p>
<p>Let&#8217;s look at another example: tracking external links. If someone clicks on a link that takes them outside of your site, you don&#8217;t have access to the data for the page they land on, so you wouldn&#8217;t know it happened. With events, you can trigger a bit of JavaScript to occur right before they leave your site. For example, let&#8217;s say I want to track how many people click on the link to my Twitter account. All I need to do is add an event:</p>
<div style="background: #fff; border: 2px dotted #eee; padding: 1em; margin-bottom: 1em;"><code>&lt;a href="http://twitter.com/cailean" onclick="_gaq.push(['_trackEvent', 'External Links', 'Click', 'Twitter']);"&gt;Follow me on Twitter&lt;/a&gt;</code></div>
<p>Now, I can track who clicked on the link to my Twitter profile, and how many times that link was clicked.</p>
<p><strong>Reporting Event Data</strong></p>
<p>Once you have your tracking set up, you can view events as they occur. Note that you don&#8217;t need to set up events in Google Analytics before you track the codes. Just like you don&#8217;t need to add every URL into Google Analytics manually, GA will track event data as it comes in automatically.</p>
<p>You can find the event tracking under Content &gt; Event Tracking. Here, you can view events by Category, Action or Label&#8230; or you can drill-down into the heirarchy to see specific subsets of the data (such as all Clicks for a particular link). You can also segment this data just as you can with normal page view data, so you can see which videos were played by people who bought products, or whether or not Canadians had a hard time filling out your forms.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-143" title="Google Analytics Events" src="http://workwebplay.com/wp-content/uploads/2010/08/Google-Analytics-Events.png" alt="" width="500" height="232" /></p>
<p><strong>Taking Action on the Data</strong></p>
<p>Event tracking is a great tool to give you some more data, but as always, the value of web analytics is always in the insights that data brings. This is where a <a href="http://www.napkyn.com/analyst-program/">web analyst</a> can dive into the data and come up with actionable things you can do to meet and exceed the business goals of your site.</p>
<p>In the meantime, I&#8217;ll talk a little more about improving and organizing your event tracking in some upcoming posts. Be sure you don&#8217;t miss them by <a href="http://feeds2.feedburner.com/WorkWebPlay">subscribing to Work, Web, Play</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://workwebplay.com/2010/08/06/google-analytics-event-tracking/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Is your web traffic seasonal?</title>
		<link>http://workwebplay.com/2008/07/26/seasonal-web-traffic/</link>
		<comments>http://workwebplay.com/2008/07/26/seasonal-web-traffic/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 21:35:21 +0000</pubDate>
		<dc:creator>Colin Temple</dc:creator>
				<category><![CDATA[Web Analytics]]></category>
		<category><![CDATA[analytics]]></category>
		<category><![CDATA[publishing]]></category>
		<category><![CDATA[trends]]></category>

		<guid isPermaLink="false">http://workwebplay.com/?p=7</guid>
		<description><![CDATA[Note: When I movedthis blog over from colintemple.com, I decided to start fresh and keep the posts more focused.  This is one of only a couple of posts that I&#8217;m moving over here, so I&#8217;m sorry if you&#8217;ve heard it all before.  This one&#8217;s originally from last September, which explains the timelines here. As we [...]]]></description>
			<content:encoded><![CDATA[<div style="padding: 1em; border: 2px dotted #aaa; margin-bottom: 1.5em;"><strong>Note: </strong>When I movedthis blog over from <a href="http://colintemple.com/">colintemple.com</a>, I decided to start fresh and keep the posts more focused.  This is one of only a couple of posts that I&#8217;m moving over here, so I&#8217;m sorry if you&#8217;ve heard it all before.  This one&#8217;s originally from last September, which explains the timelines here.</div>
<p>As we go about our lives throughout the year, our patterns change. In the summer, we&#8217;re more likely to be on vacation, or outside enjoying the sun. In the winter, we&#8217;re more likely to spend more time indoors, maybe at the computer. Your occupation might also change dramatically from season to season, whether you&#8217;re a student, botanist, hockey player or lifeguard.<span id="more-7"></span></p>
<p>So it&#8217;s no surprise, then, that the time of year will make a big difference on your web traffic. Of course, any ecommerce or consumer-focused site will notice a lift in the November-December holiday season. But what other factors influence your traffic?</p>
<p>I was just looking through my Google Analytics account when I noticed that one of my sites, <a href="http://www.ancient-mythology.com/">Ancient-Mythology.com</a>, had picked up a bit over the past two weeks. I took a step back and looked at the charts for the past two months, and realized that my traffic was coming out of a two-month lull. Curious, I took a look at the past 22 months of data. The answer was obvious.</p>
<p style="text-align: center"><img class="alignnone size-full wp-image-6" title="Seasonal Web Traffic" src="http://workwebplay.com/wp-content/uploads/2008/07/seasonal-traffic.jpg" alt="" width="481" height="55" /></p>
<p>It doesn&#8217;t take a degree in rocket surgery to put this one together. As my clever clip-art inserts demonstrate, my traffic was down every summer and during the Christmas holidays. This is a strong indicator that my mythology site is being used primarily by students, most of whom are probably working on a high school class project, or studying humanities or religion in college.</p>
<p>We tend to look at our stats on a week-to-week or month-to-month basis, but there&#8217;s plenty to be learned by looking at the big picture. So take a look at your stats over the past couple of years. Your niche may have an annual pattern &#8212; and you might learn who&#8217;s really visiting your site, as I did.</p>
<p>Once you&#8217;ve figured this out, capitalize on it. Organize your marketing campaigns and major site updates according to these patterns, so your site is at its prime when you have the most visitors. Use this data to determine the needs of your visitors at the time, as well. For example, I might see success if I were to advertise or affiliate with other student resources, or services offering essay-writing help.</p>
]]></content:encoded>
			<wfw:commentRss>http://workwebplay.com/2008/07/26/seasonal-web-traffic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
