This blog post is for the analytics driven, SEO savvy, search samurai looking to implement tracking code best practices and take advantage of some useful Google Analytics plugins.
The focus of this post is on Google Analytics, but many of the concepts are also applicable more generally, no matter what web analytics platform you're using.
Tracking Code Basics
Asynchronous Tracking Code - Even before the asynchronous tracking code was rolled out, I was a believer in putting the GA tracking code in the header, rather than before the closing body tag, which is where Google recommends placing the tracking code. With the announcement of asynchronous tracking code, which loads in conjunction with the page as opposed to sequentially, however, you can now have your cake and eat it too. You can get the benefit of your data not being compromised by slow page load times and also keep from getting push back from the developer that implements your tracking codes.<script type="text/javascript">Expanding Goal Limitations - Without setting up goals, your GA account is a glorified hit counter. So it's imperative that you set up goal or eCommerce tracking (if not both). When setting up your GA goals in your analytics settings, you can either use the expanded goals, which allow you to track up to 20 different URLs or engagement metrics per profile. It's important to realize, however, that you can also set your goals up so you can track hundreds or even thousands of goals. All you have to do is set up a logical hierarchy where the root of your goal URLs trigger your goal events. For us at SEOmoz, this might mean we have a tool run goal event triggered with /goal/tool-run - yet we also have the added granularity down to the individual tool level should we ever want to see which tools are being run the most or to segment traffic based on visitors who ran a particular tool.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
'https://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
eCommerce Tracking - Justin Cutroni did a great job with his series of blog posts that walk through how eCommerce tracking works, installing & setting up eCommerce tracking, explaining why everyone should use eCommerce tracking, & tracking lead gen forms. In addition to eCommerce tracking, not to be forgotten is using SetVar or a custom variable to segment repeat or premium buyers. For example, say your site gets 5 sales from keyword #1 and 5 sales from keyword #2. If sales for keyword #1 are each $800 and sales from keyword #2 are $10 each, you're going to want to segment that traffic and make on-page optimizations by looking at the on-site behavior of your premium buyers who converted on keyword #1, rather than from keyword #2.
Custom Variables for Registered & Non-Registered - One of the most powerful aspects of GA is the ability to set custom variable. Custom variables can be set at any of three levels (visitor, session, & page). The Google Analytics help documentation is particularly great, but EpikOne also has a worthwhile description on how custom variables work. The most powerful of these is the visitor level custom variable which allows you to cookie a visitor across multiple sessions. At SEOmoz, we use this to track three different member types: free members, PRO members, & canceled members. We also use custom variables to cookie at the session level.
Campaign Tagging & SetAllowAnchor - From widgets to newsletters to signature links in personal e-mails, campaign links should be tagged using the GA URL builder, which gives you tracking parameters that includes multiple, including required _utm values for source, medium, & campaign. In action this looks something like this:
https://moz.com/?utm_source=newsletter&utm_medium=email&utm_campaign=march-6-2010
When tagging your campaigns be aware that by default GA will only recognize tracking parameters if the string is kicked off by a question mark, which from an SEO standpoint can lead to diffusion of link juice and duplicate content issues. To avoid these issues, we you can kick off campaign parameters with the hash tag and modify your GA tracking code using the SetAllowAnchor attribute, so GA recognizes the hash tag as way to kick off a campaign tracking URLs. To do this, add -- pageTracker._setAllowAnchor(true); -- to your main GA tracking code between the var pageTracker and pageTracker attributes. Or, for additional documentation, read LunaMetrics' blog post on using SetAllowAnchor, but the code should look something like this:
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-0000000-1");
pageTracker._setAllowAnchor(true);
pageTracker._trackPageview();
} catch(err) {}
Tagging Email - One of the most important areas you can apply campaign tagging is e-mail. And though you can get fancy and create a filter that combines email sources you should not have to do this because your campaigns should be tagged to begin with. So definitely follow what the experts say about tagging email campaigns, but I am a huge fan of bucketing your reports by segment and grouping based on conversion goal. For example, at SEOmoz we're rolling out a number of e-mails ranging from a customer lifecycle welcome series to newsletters to follow up emails after PRO members cancel. Rather than doing one off tracking, our GA tracking is set up in a way that we can aggregate by visitor type. This allows management to quickly look at the all up numbers and see how e-mail is driving each goal area of the business: activation, retention, and re-activation.
And if you use a logical naming convention with your email tagging, such as the one shown below, your marketing team will be able to splice and dice using regular expressions to get a much more granular view of performance for each email format, type, or version:
- Email Format: Which types of emails are doing best (i.e. newsletters, promotional emails, system notifications, etc.)
- Performance by Email Type: Shows the breakdown of which email types have the greatest volume and/or the lowest click through rates. And thus, where you should place your testing and optimization energy. (i.e. emails sent 1 week after sign up, promos sent in December, etc.)
- Version Number: Allows you to test subject lines and e-mail variants to see which versions are driving the most conversions, engagement, or retention. (i.e. subject line #1, subject line #2, etc.)
Vanity URLs - If you're running an offline campaign, such as a magazine ad, a business card run or a billboard creative, you're not going to want to use the long URL builder parameter. As WebShare's Corey Koberg shows in the below graphic, long URL parameters don't work for offline. So you'll likely be much better off measuring offline efforts with a short, easy to remember vanity URL, which, in order to keep your metrics from being skewed as a result of page load times, you'll want to implement using a 301 redirect, rather than using meta refresh.
Google Analytics Plugins
Though not on the list of must haves for the search samurai, I'm a sucker for a great browser plugin. And as ROI Revolution blogged about, there are a handful of browser plugins for GA that you might find are worth installing. Three plugins I use with varying degrees of regularity are:Does a Page Have GA?
If you're checking a lot of pages on your site to see if they have tracking code installed or if you want quick, at a glance reference as to whether or not a page on another site has GA tracking code, Twistermc's GA? Firefox plugin is a great way to see if GA is installed without having to view the source code. The way it works it works is simple. If a page has GA installed, the bar chart that appears in the lower right hand corner of your browser is illuminated. If the page does not have GA installed, the bar chart is not illuminated.
Which Referring Sites & Keywords Have Changed?
Similar in concept to a custom alerts, the Better GA plugin by Juice Analytics provides a useful way to drill into your referring sites or referring keyword reports and see which sites or keywords have fluctuated the most over the last few days or week.
Better Google Analytics:
Perhaps the most robust GA plugin of all is VKIs studios' greasemonkey script based plugin, which offers a number of bells an whistles, including page level social media data from sites like Digg, Reddit, StumbleUpon, and Delicious (see below),as well as added functionality such as a direct entry field to access your top content report from any other report, direct links to export to Google Docs, and a half dozen or so others.
For more comprehensive information on Google Analytics, I encourage you to read through Google Analytics' help documentation or tapping into some of the great web analytics resources available such as Google Analytics' Official Blog, Webshare's Blog (their Google Analytics 101 posts are particularly good,) LunaMetrics, EpikOne, & Avinash's Occam's Razor - each of which are full of Analytics tips from top-notch experts.
Also, special thanks to David Booth at WebShare for his help with SEOmoz's implementation of Google Analytics and also for sharing several of the insights included in this post. For more info on GA and GWO, WebShare's Google sponsored Seminars for Success, which I attended last year, and which the SEOmoz marketing team will be attending here in Seattle on May 12-14th, are among the most educational and best valued around.
It's great! It will definitely save some time for me :)
If your looking for a good analytics plugin for firefox I quite like using WASP which picks up the analytics on the page, useful for doubleclick etc as well.
Thanks for the heads up on the Web Analytics Solution Profiler (WASP)plug in robbothan. I hadn't known about it.
Yeah, WASP is really slick!
I use WASP too. It shows all the analytics tools installed on a website (it tracks more than 150)It can also crawl your website to see if you forgot to tag certain pages.
Thumbs up to Stephane Hamel from immeria.net for developing this usefull tool.
Thank you. It's nice having all of the information on a single page. A lot of what you've written has been said before, but spread across several different websites/pages.
Top of the pile of SEO knowledge that I don't have and must get around to is my own analytics. Granular data? Mine's monolithic!
I've read this piece twice and while none of it really makes much sense to me right now, I can tell that this post and the resources it points to are going to put a spike in my learning curve like it's pleased to see me. For something this good to fall into my laptop leaves me a bit speechless.
Thank you so much. I'm now going to cry tears of geek joy.
Hi sam,
one thing worth mentioning is that many email marketers who use campaign-tracking make the mistake of hiding the tracking url by using the canonical url as the anchor text. While this might seem a good idea, it is actually not: Many email clients including Mozilla Thunderbird see this as a sign of phishing.
So, if you want to hide the tracking urls, you should use a picture (which should of course be attached to the email and not be loaded externally).
This is great information. Has anyone read Web Analytics 2.0 yet? It's getting great reviews on Amazon.
Avinash also donates 100% of proceeds from the book to charity.
SEO and Analytics should have been combined more thoroughly before now even as I see it because how can you truly track success if you are not analyzing?
I see an SEO's job as being one of increasing revenue, ROI, instead of just driving traffic; therefor, without tracking goals and conversions, how are you suppoosed to call yourself a good SEO?
i completely agree, although its difficult to explain this to the client whose "aim of SEO" is to "drive more traffic"
We SEO's need to re-educate clients all too often
I've used analytics since I started, but very few clients have a handle on what they offer. For most, their understanding of SEO is how far up (or down) the SERPs they appear. I have about 20% who have an ongoing analytics reporting contract, but most just don't see it for the opportunity it offers.
Coming from a long career in offline marketing, SEO without measurement is like building race cars without knowing what track they are going on - desert racing or Indy? (note US example). sure they'll be powerful, but if you want to win you need to adapt to the track.
If clients have an ecommerce site they can see some figures, but even with the seemingly ubiquitous AWstats I've seen little awareness of the power of SEO combined with analysis.
The client's knowledge gaps are obvious - first one needs to explain personal search and the relative value of click-throughs vs position, bounces and even keywords. They just don't know they need to know, so it behoves us to educate them.
When they understand the power of SEO and analytics ...
Great article, thanks Sam. I'm looking forward to satisfying the increasing demand for web analytics and SEO.
Nice list!
trying out that firefox addon tomorrow.
thanks for the post
Fantastic post! i'm currently taking the Web Analytics Master Cert course with Avinash and John Marshall and can't get enough of this stuff. Bookmarked!
Where can one get more information on the certification course you're taking? Any info would be appreciated! Thanks.
Recently, Avinash mentioned a really helpful tool for use with GA. The tool is called the dimensionator (or something like that)and it gives you more options to use while viewing reports.
It enables you to add extra primary, secondary and pivot table dimensions.
The site is: https://www.analyticspros.com/resources/90-analytics-toolbar.html
In 2008 I started to fell in Love with Web Analytics and what I can learn from it to better SEO.
In 2009 there was a much stronger Engagement with Analytics. They are a great pair that seem go perfectly hand in hand.
Will 2010 be the year that we complete the marriage between SEO & Analytics and become SEMA's (search engine marketing analysts)?
---
Ok, I just might have read too many Valentine themed posts this week!
:-)
you put the tracking code at the bottom of the page because if the google servers are down/slow it will not slow or stop your page from loading.
It did happens once and Google changed their policy after that.
as we move from Omniture and into GA, I am more excited about the potential and the possibilities.
thanks for this gem!
Great collection of tips, Sam. I'm actually in the middle of reading "Advanced Web Metrics with Google Analytics" by Brian Clifton, and it has some great advanced stuff as well. It's well worth a read to anyone wanting to dive deeper into GA customization, but word on the street is that there's a new edition coming out soon, so you may not want to but it just yet.
Great post.
I'm just wondering with setallowanchor will GA track both ? and # or is it only one or the other?
At the moment the media agency has all display and PPC set to track using the ? but I want to track SEO using the # but if I turn setallowanchor to true will it stop tracking the display and PPC?
Thanks
Another better plugin that i have been using for well over a year is WASP
https://webanalyticssolutionprofiler.com/
Its not free but damn its useful :)
Great post!
I learned a couple of things here that will have an immediate impact.
1. The SetAllowAnchor to change the tagging paramater in the URL from ? to #. That is a new one. I will be working that one in tomorrow.
2. The plugin you reference from VKIs studios....it looks great! I went to download it, but got an error message that it didn't work with FF v. 3.6.4 Bummer.
I spend a lot of time using the 'Service Provider' report under the Visitor Profiling. Being in a B2B business it helps with knowing which businesses are looking on our site; provided they're not on qwest business or comcast business..... Segmenting the businesses by Service Provider and then matching with content is very helpful in crafting messaging for direct contact or unique emails from sales reps.
Interesting, post.
Not sure I quite understood everything though, its most likely going to be one of those posts I'll come back to when I'm more into GA, (which I know I should be doing!). But for started already downloaded the GA pluggins so will see how that works.
Thanks for the heads up!
@Sam awesome to see that the process has been going so well, and it is all laid out in sections.
Great Post! Definitely worth recommending it...
Excellent Post - tweet tweet
Note to self - learn more analytics starting here!
This article still holds true! Great refresher
Hold the presses! This was a smokin' hot post Sam! I predict you're going to get a ton of traffic to this post.
I cannot get enough of Analytics how to's, especially when they're as information rich as this one.
Thanks Sam.
awesome post sam!
analytics, tracking techniques and variations and reporting are some of the hardest things, imo, when executing a SEO campaign.
love the asynchronous part, as well as the custom variables and e-commerce tracking. actually, currently working on getting some bugs fixed with GA and some e-commerce software we implemented for a client where it shows all transactions as referrals from the root domain of our clients site. [went from site, to 3rd party cart, back to site and counts the transaction as a site referral, and no other metrics are given besides e-comm metrics. blast. i'll figure it out soon enough].
anyway, cheers!
By the way, the link from the anchor text "how custom variables work" is a 404..... (and I was so excited to learn more....)
fixed! :)
Great post. Very Delicious-worthy. I didn't know about the custom variables! Thanks for the tip.
The defualt cookie setting in Analytics is 6 months, what is good time to track SEO visits and other trafic souces.
Sam, thanks for the link to the E-mail filter :)
Fantastic Report. This is going to help a lot, especially with the increasing limits of Google Analytics.
Perhaps a follow up to this would be how to utilise funnels to their best potential.
Very comprehensive. Some of the stuff you've listed; I've never even seen before. E.g. VKIs studios' greasemonkey script based plugin ...just awesome.
Also, I am a big proponent of utilizing the GA asynchronous tracking code.
...and as you've pointed out, I believe we will be seeing a whole lot more of a fusion between SEO and analytics experts.
Hello Sir,
I am already use google analyatics and google adword tool for optimize my campaign but i have one problem with converion tracking tool as many customers visted my website and also they successfully reach or end with at last where my code resides for conversion happened but in conversion feild of mine still showing zero and i want to know why this happens can u plz reply me on my mail id or just mail me when u reply on my comment at ([email protected]).
Thanks and Regards,
Prem Goyal
Seo Master India
Great stuff :-) Remember Rand got a question when in Oslo (semkonferansen) a while back: if you could only do one thing for seo what would that be?
He paused for a long while, but then answered "Analytics, I would do Analytics"
By the way..
All Chrome (beta) lovers -> Extension that shows if GA is installed or not:
https://chrome.google.com/extensions/detail/hfildnjlegfhkamejpekkfhinijcgloh
(pardon the frenche url)
Amazing post, Sam! Well done.
I will definitely check these time saving plugins! they look great and surely they will make my life easier.
Thanks!
Great post Rand.
Only other really useful function I'd add in is Event Tracking. This has some powerful uses, especially tracking user interaction.
I've found it really useful on sites where the user is taken to a 3rd party payment gateway. You can track the last action on your site which gives a total of people entering the payment gateway (eg on the 'buy button'), then of course put tracking (goal, adwords conversion) on the recipt page when the user returns - great for measuring checkout drop off and v.simple to implement.
_trackEvent(category, action, optional_label, optional_value)
Better check the author again!
Believe it or not, Rand doesn't write EVERY single article on SEOmoz.
The kudos should go to Sam Niccolls.
Exactly! Sam put a lot of work into this post and deserves the props! :)
Good stuff! Sphunn!
https://sphinn.com/story/141239