Google Analytics E-Commerce Tracking Pt. 2: Installation & Setup

January 22, 2008 by Justin Cutroni

This is part 2 in my series on Google Analytics e-commerce tracking. In part 1 I described, at a conceptual level, how GA e-commerce tracking works. In this post I’ll get into the specifics of the code and how to install it.

This isn’t the most exciting stuff (that will be part 3), but a correct setup leads to correct data. :)

Step 1: Activate the Reports

The first step in setting up GA e-commerce tracking is enabling the e-commerce reports. Log into GA and edit the profile settings. Specify that your site is an e-commerce site. This activates the e-commerce reports.

Google Analytics E-Commerce Reports

There are other e-commerce settings that don’t get much use (unless you’re an international site). You can specify one of 25 different currencies (wow!) and the number of decimal places you would like displayed (1,2 or 3). Even if you use USD you can specify 3 decimal places. Go ahead and try it, it’s interesting.

Remember, e-commerce reports is a profile setting that is “off” by default. You’ll need to activate the reports for each new profile you create.

Step 2: Tag your Receipt Page

I know this seems like a silly step, but make sure you add the GA tracking code you your receipt page. You must have the standard GA tracking code on your receipt page in order to track transactions. The reason is that the e-commerce tracking code is stored in the ga.js. If this file is not included on the receipt page then you can’t track transactions.

Step 3: Install the Code

This is the hard part: code construction. As we learned in part 1, GA uses a JavaScript collection technique to track e-commerce transactions. Your server code must inject transaction information into the GA JavaScript before sending the receipt page back to the browser. When the receipt page renders in the visitor’s browser the JavaScipt executes and sends the transaction info to GA.

Get ready for some construction.

Let’s take a look at the code:


<script type="text/javascript">
pageTracker._addTrans(
      "order-id", // required
      "affiliate or store name",
      "total",
      "tax",
      "shipping",
      "city",
      "state",
      "country"
); 

pageTracker._addItem(
      "order-id", // required
      "SKU",
      "product name",
      "product category",
      "unit price",  // required
      "quantity"  //required
); 

pageTracker._trackTrans();
</script>

The three parts of GA e-commerce trackingThe first thing that you’ll notice is that there are three distinct parts to the JavaScript. Each is a different method. The first section, identified by the _addTrans() method, creates the transaction and stores all the information about the transaction.

The second section, identified by the _addItem() method, is used to add an item to the transaction. You need to create an _addItem() section for each different item, or SKU, in the transaction. The order ID in the _addItem() method must be the same order ID used in the _addTrans() method. That’s how GA ties an item to a transactions.

The final section is the _trackTrans() method. This method actually sends the data to GA by requesting the __utm.gif file once for the transaction and once for each item in the transaction. So if you have 3 different SKUs in a transaction there will be 4 requests fot the __utm.gif.

The above JavaScript can appear anywhere on your receipt page. Just make sure that it appears after the main GA page tag. The reason is that the e-commerce code is part of the pageTracker object. If the pageTracker object has not been created then you can’t call the e-commerce methods.

Just to reiterate a point: you must create server side code that outputs the transaction data in the format above. If you do not have access to your shopping cart code, and your cart provider does not provide e-commerce tracking, then you may be out of luck.

Once the code has been installed you should begin to see e-commerce data in your reports.

Notes and Suggestions

Like many things in Google Analytics, there are some things that can trip you up:

  • If you do not wish to pass a certain piece of data to GA then do not add anything between the quotation marks. The only required fields are the order ID, the unit price of each item and the quantity of each item. Everything else is optional.
  • Do not use currency identifiers or commas (to separate thousands) in any of the numeric fields (i.e. total, tax, shipping). These characters have caused problems in the past.
  • Each piece of transaction data that you send to Google Analytics becomes a data element in GA, just like any other piece of data in GA (geo data, campaign data, browser data, etc.). You can do all sorts of neat things with filters and e-commerce data. More on this later.
  • The affiliate or store name field is no longer used in the GA reports. However, the data is still collected by GA so you can use it in a filter.
  • The transaction geographic data collected by GA is no longer used BUT it is collected. Google Analytics determines the location of the user, and thus their transaction, based on their IP address. The old version of the GA tracking code used the data specified in the transaction. Like the affiliate field, the data can be used in a filter.

Up Next

In the next post I’m going to talk about some creative ways to use e-commerce tracking. Specifically, why I believe that everyone should use e-commerce tracking on their website.

Subscribe:

Google Analytics E-Commerce Tracking Pt. 1: How It Works

January 13, 2008 by Justin Cutroni

This post is the first in a series of e-commerce transaction tracking with Google Analytics. Why is e-commerce tracking important? Well, transaction data is a vital piece of information when analyzing online business performance.

Sure, it’s great to measure things like conversion rate, but revenue is much more tangible to many business owners. Having the e-commerce data in your web analytics application makes it easier to perform analysis. Do you need to set up e-commerce tracking? No, but it sure helps. :)

The Big Pictures

E-commerce tracking is based on the same principal as standard pageview tracking. JavaScript code sends the data to a Google Analytic servers by requesting an invisible gif file. The big difference is that e-commerce data is sent rather than pageview data.

But how does Google Analytics get the e-commerce data? That’s the tricky part. You, the site owner, must create some type of code that inserts the transaction data into the GA JavaScript. Sounds tricky, huh? Well, its not that bad.

Step by Step: How it Works

Let’s break it down and walk through what actually happens.

1. The visitor submits their transaction to your server.

2. Your server receives the transaction data and processes the transaction. This may include a number of steps at the server level, such as sending a confirmation email, checking a credit card number, etc.

3. After processing the transaction the server prepares to send the receipt page back to the visitor. While preparing the receipt page your server must extract some the transaction data and insert it into the Google Analytics JavaScript. This is the code that you must create.

4. The receipt page is sent to the visitor’s browser.

5. While the receipt page renders in the visitor’s browser the e-commerce data is sent to Google Analytics via special GA JavaScript.

Here’s a basic diagram of the process. Again, the biggest challenge during implementation is adding code to your web server that inserts the transaction data, in the appropriate format, into the receipt page. I’ll cover the setup in part 2 of this series.

What Data can be Tracked?

Google Analytics collect two types of e-commerce data: transaction data and item data. Transaction data describes the overall transaction (transaction ID, total sale, tax, shipping, etc.) while item data describes the items purchased in the transaction (sku, description, category, etc.). All of this data eventually ends up in GA reports. Here’s a complete list of the data:

Transaction Data

  • Transaction ID: your internal transaction ID [required]
  • Affiliate or store name
  • Total
  • Tax
  • Shipping
  • City
  • State or region
  • Country

Item Data

  • Transaction ID: same as in transaction data [required]
  • SKU
  • Product name
  • Product category or product variation
  • Unit price [required]
  • Quantity [required]

A few notes about the data. First, the geo-location data is no longer used by Google Analytics. The new version of GA tries to identify where the buyer is located using an IP address lookup. Also, you should avoid using any non-alpha numeric characters in the data. Especially in the numeric fields. Do not add a currency identifier (i.e. dollar sign) in the total, tax or shipping fields. this can cause problems with the data.

Coming Up Next

Next time, in part 2, we’ll look at the code and how to actually add it to your site.

Subscribe:

2008 Google Analytics Resolutions

January 8, 2008 by Justin Cutroni

Happy new year! I can’t believe 2007 is over. Continuing with a tradition I began last year, I give you my 2008 GA resolutions.

Before I get into the list, I want to thank everyone who reads and contributes to Analytics Talk. 2007 was an incredible year for me, and I really owe a lot to you guys. Thank you for reading, posting questions and helping me learn so much.

1. I will migrate to the new GA.JS tracking code.

Google announced a new version of the tracking code, ga.js, in October 2007 and launched the new code in December. After some minor launch problems things seem to be running smoothly. While you don’t need to migrate to ga.js, you should start to think about it because Google will no longer add features to urchin.js. In my opinion, you should tackle this problem sooner rather than later.

2. I will contemplate Event Tracking and how I can use it.

The reason Google introduced a new version of the tracking code was to enable a powerful new feature called Event Tracking. While most folks might think of event tracking as a ‘web 2.0′ tracking tool geared towards video players and Ajax, it’s really a flexible framework for data collection. I was skeptical at first, but now I’m a convert. All of us can take advantage of this new feature.

I’ll be writing more about Event Tracking and its uses when Google pushes the feature to everyone. In the mean time, check out this series of posts to learn more:

Event Tracking Pt. 1: Overview & Data Model
Event Tracking Pt. 2: Implementation
Event Tracking Pt. 3: Reporting & Analysis

3. I will get creative with profiles.

This is something I’ve been talking about for a while. Profiles are so much more than website data. They’re a collection of data and business rules. Last year, as part of my 2007 resolutions, I mentioned setting up test profiles as a way to insure your configuration settings are correct.

For 2008 I suggest setting up profiles for all major marketing campaigns and mediums. Why? So you can segment reports that normally can not be segmented. Check out Segmenting Visitor Loyalty Reports in GA for more information.

4. I will try some type of ‘advanced’ Google Analytics configuration.

Most of us have a fairly basic implementation of GA. We don’t need to do much more than add the tracking code to our site, set up goals, and configure on site search reporting.

Why not try something new this year? How about using an ‘advanced’ feature like custom segmentation, event tracking or even e-commerce tracking? All of these features can help you learn more about your visitors and what they do. That’s why we use these features and try these hacks: to gain insight and knowledge.

5. I will keep track of website changes and Google Analytics changes.

This is something that I wrote about a long time ago, but it’s still really important. It’s a good idea to keep track of your GA configuration changes so you can better understand the data. Any modifications, like a change to a goal, funnel or filter, should be recorded.

It’s also a good idea to keep track of website changes and online marketing changes. Knowing what’s going to happen with your online business helps drive analysis and you’ll be able to deliver data that will make people happy.

You don’t need anything elaborate, a simple Google Spreadsheet, like this one, will work just fine.

There you have it, a few ideas to spice up your 2008 Google Analytics plans. Got a better idea or think that I missed something? Leave a comment below. And happy new year!

Subscribe:

Surprise! New Google Analytics Features

December 13, 2007 by Justin Cutroni

It looks like the team at Google Analytics has surprised us all with some new features. What a great way to celebrate the holiday season. Many of these new changes were actually announced by Brett Crosby at Emetrics and are just now getting rolled out to all of us.

New Multi-Line Graph

Google has added a new features to help with analysis. It’s called multi-line graphing. We now have the ability to graph multiple lines of data in the data-over-time graph that appears at the top of each page. There are two ways to use this feature.

Google Analytics Multi-Line Graphing

First, you can compare two metrics in the graph. This is a great way to determine if there is a correlation between the two numbers. For example, let’s say you want to see if conversion rate stays the same if visits increase. Now you can do that.

Google Analytics: Graph two metrics

The second way to use the multi-line graph is to compare a specific segment of data to the overall site data. This helps you analyze how much the segment of data affected the larger set of data.

The graph below shows AdWords visits (blue) and the total site visits (gray). We can clearly see that there was a big bump in traffic but it was not caused by AdWords.

Google Analytics: Compare Data to Site Average

I’ll have a more in-depth post on this tomorrow.

New ga.js Tracking Code

The new ga.js tracking code is now live. For those of you that don’t know, Google created a new version of the tracking code that supports many new features, primarily event tracking.

The new tracking code is very different. Many of the functions that exist in urchin.js do not exist in ga.js. Things like urchinTracker() and __utmSetVar() are gone. Don’t worry, they’ve been replaced with new methods like _trackPageview() and _setVar().

You don’t need to migrate to the new ga.js, you can continue to use the old urchin.js. However, Google will not update urchin.js in the future. If you want to take advantage of new features you must upgrade.

Check out GA.JS: New Google Analytics Tracking Code for more information about why the basic page tag has changed, how it has changed and if you should upgrade to the new tracking code.

To help facilitate the transition, Google has published a migration guide to help you transition from urchin.js to ga.js. It’s a great resource that does a good job of mapping old tracking code settings to new tracking code settings.

How do you get the new tracking code for your site? For existing websites, there is a new tabbed interface that provides the urchin.js tracking code or the ga.js tracking code. Just click on the “Check Status” link for a profile and you’ll see the tabs. Google will automatically supply the new ga.js tracking code when you create a new profile.

Google Analytics Tracking Code Tabs

Caution: do not use the new tracking code and old tracking code on the same page. However, you can use the new tracking code on some parts of your site and the old tracking code on other parts of the site.

Subscribe:

Google Analytics: Thoughts on the Future

December 4, 2007 by Justin Cutroni

I am continuously amazed at how fast our industry changes. In the two years since Google Analytics was launched we’ve seen Web Analytics grow in popularity and web analysts become highly prized in the marketplace. Many people attribute the change to Google Analytics which got me thinking about GA and how it may evolve in the future.

I’d like to mention that this post is purely opinion and speculation. I have no idea what Google’s master plan is for Google Analytics, but I do think that my ideas are possible.

picture-6.png

Let’s start by looking at where Google is going as a business. Google’s long term strategy is to become the dominant advertising network on the planet. It’s something that CEO Eric Schmidt has talked about in the past and it make total sense. The more advertising options that Google can offer it’s current customers the bigger the opportunity for growth.

Google’s success relies on the adoption of said advertising tools. Look at AdWords and the insane revenue it generates. Now image if Google could create 3 or 4 more advertising products that are as successful as AdWords. We’ll be looking at Berkshire Hathaway stock prices in no time.

The expansion of Google’s advertising platform began with audio ads and print ads and I’m sure they’re not going to stop there. These new products are simple, thus making them accessible to businesses that may not normally branch out into a new advertising medium. I’ll talk about specific Google advertising products and my thoughts on each in a moment, but what does all this mean to Google Analytics?

No matter what advertising tools Google creates, there needs to be a centralized reporting and analysis component. GA is that piece of the puzzle. It’s no secret that Google wants to create the Google Marketing Dashboard, why not base it on Google Analytics? It makes complete sense, right? GA is a data analysis tool so why not use it to analyze all marketing data? At the very least GA should be the analysis piece of the puzzle.


That’s the long term vision, but what type of integration opportunities exist right now?

The most basic integration is the inclusion of advertising cost data into Google Analytics. Audio cost data, print cost data… it’s natural to think that these will be pulled into GA soon.

The next integration step should be the automatic identification of online traffic that originated with an offline ad. Image if you could automatically create vanity URLs for your audio or print campaigns and have GA automatically track them. We’re already doing this manually, but it could, and should, be automated by Google. This type of integration will further remove IT from the configuration of GA making it easier for all types of organizations to track offline marketing efforts.

Let’s get even more specific.

Google AdWords

picture-1.pngNo need to talk much about this one. Google is the 800 pound gorilla in the paid search world. AdWords campaigns are automatically tracking in Google Analytics and cost data is automatically imported to compute ROI. Pretty slick. It would be nice if Google could pull in cost data from other paid search vendors, but there are probably too many political hurdles for this to happen.

Google Audio Ads

picture-2.png
I mentioned this one above and wrote a post about tracking audio ads with Google Analytics it in the past. I think audio integration is pretty logical. Beyond the cost data, I would like to see some type of map overlay report correlating geographic web traffic and the distribution of audio ads. The addition of automatically created vanity URLs for audio ads would provide a slick way to connect online conversions to the originating audio ad.

Google Print Ads

picture-3.png
Print is very similar to audio and I think it’s something we could see soon. Many of the same integration points exist for print ads including cost data, a map overlay of ad distribution and web visits and an automatically created vanity URL for print ads.

Graphic (Banner) Ads

This is another one that could be very close. Once the purchase of DoubleClick is finalized I bet we’re gong to see DoubleClick’s pre-click data rolled into GA quickly. Maybe they’ll add a DoubleClick item to the Traffic Sources menu below the AdWords menu item.

I think we’ll also see an auto-tagging feature for ads displayed on DoubleClick’s network. No more tagging destination URLs. Woo hoo!

Mobile

picture-7.png
Everyone loves to talk about mobile tracking. But the fact is that mobile tracking right now is miserable. The inconsistent implementation of JavaScript on mobile devices makes it very hard to track visitors on mobile devices.

Google has taken a big step to improve mobile tracking with the announcement of Android. This isn’t just a mobile browser, it’s a complete platform for mobile devices. It’s also a way that Google can insure that they’re very involved in the future of the mobile web. I’m sure that Google will include some type of mechanism in Android to track visitors.

Video (Google Video & YouTube) Ads

picture-8.png
Google is poised to provide some amazing data about how people interact with video. The new Google Analytics Event tracking feature is a logical, structured way to measure visitor engagement with video and video ads. I really hope that event tracking is added to all YouTube videos so we can all measure the performance of video content. Once we know how visitors are engaging video we can choose optimal placement of video ads.

I also expect Google to facilitate the creation of video ads in the same manner they did with audio ads and print ads. Maybe they’ll create a video ad marketplace.

Email Marketing

Google does not have an email marketing solution, but why couldn’t they leverage Gmail and create one? Just add a basic interface where users can upload a recipient list and some type of interface where they can style the email and you have a very effective email marketing tool.

But what about all of those people that don’t use Google advertising tools? What if someone just wants to use GA to measure website traffic? What cool features can they expect from Google?

I think Google’s commitment to GA goes well beyond the integration of advertising data. Google has a vested interest in providing tools that help EVERYONE make the web a better place. Part of Google’s philosophy is to, “Focus on the user and all else will follow.”

Analytics is one of the tools (and the most mature, I might ad) that Google provides so we can all make the web better (Website Optimizer and Google Trends are two others). The more analysis features that Google can pack into GA the more effective we’ll all be at making our sites better.

picture-5.pngCase in point, GA version 2. It was a major improvement in analytics UI design that facilitates analysis. Is it perfect? No, of course not. But it really makes analysis easier for everyone. I expect that Google will continue to refine the reporting interface by giving us more data visualization tools and more context for our data.

So what does this mean to other analytics vendors?

I don’t think that any other analytics vendor will be able to track Google based advertising (AdWords, Audio ads, etc.) as well as Google. I know that seems obvious, but it is a big deal, especially when Google becomes the major advertising network on the planet. Google can provide a view of offline ad activity and the resulting online behavior because they will have all the data. Could other providers create similar reporting? Maybe, but it won’t be as easy.

I also believe that we’ll continue to see consolidation. Google has, in my opinion, made web analytics tools (and testing tools) a commodity. Is there still a need for $250,000 web analytics application? Maybe, but I guarantee you people are taking a closer look at GA and evaluating the features that they really need before dropping hundreds of thousands of dollars.

Think I’m nuts? Think OmniSciences will take over the world? Leave a comment and let me know.

Subscribe:

Tracking Sub Domains with Google Analytics

November 19, 2007 by Justin Cutroni

Tracking websites that have multiple sub domains may not seem like a complicated thing. In fact, the GA support docs clearly outlines two ways to track sub domains. You can track all sub domains in a single profile or you can track sub domains in separate profiles.

But what if you want more flexibility? What if you want to track one group of sub domains in one profile and a different group of sub domains in another profile? Or what if you want to create new profiles for a different groups of sub domains in the future?

I like to use an approach that let’s you decide how you want to group sub domain traffic. This setup will give you the most flexibility now and in the future. Some of the benefits include:

1. It let’s you collect all data in a master profile. This facilitates ‘roll up’ reporting and gives you an easy way to measure traffic to the primary domain and all of the sub domains.

2. This technique lets you track each individual sub domain in it’s own profile which is useful for deeper analysis.

3. You can easily create new profiles in the future based on groups of sub domains.

Here’s the exact process to get this working.

1. Create Profile for The Primary Domain

The first step is to create a master profile. All other profiles for the website, including profiles for the various sub domains, will be based on this profile. When you enter the domain for the website use the primary website domain. In the example below, I’m using www.sitedomain.com as the website domain.

Google Analytics Master Profile Settings.

After creating the profile GA will display the tracking code for the site. Before you add it to your pages it must be modified. You need to force GA to use the primary website domain for the cookie domain. This modification will let you track each unique visitor across all sub domains. This in turn let’s us collect all site data in a single profile and do ‘roll up’ reporting.

Old urchin.js tracking code:


<script type="text/javascript">
_uacct = "UA-XXXXXXX-1";
_udn = "sitedomain.com";
urchinTracker();
</script>

New ga.js tracking code:


<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._setDomainName("sitedomain.com");
pageTracker._initData();
pageTracker._trackPageview();
</script>

Use this profile as a way to measure overall traffic across all of your sub domains. To facilitate page analysis in this profile add a filter that concatenates the hostname to the Request URI, which is the piece of data in the Top Content report. This will help you differentiate traffic to pages with the same URI that may reside on different sub domains.

20071118-hostname-request.png

A handy report that you’ll want to use in this profile is the Visitors > Network Properties > Hostnames report. This report will show traffic to the primary domain and all of the sub domains. It’s an easy way to compare traffic to the various sub domains.

2. Create Profiles for All Sub Domains

Once you have created the master profile you can start creating profiles for each of the sub domains. Remember, each sub domain profile is based on the master profile, that we created in step 1. Here’s how to set up the new profile:

20071118-sub-profile.png

Now that you’ve created the profile, make sure you add the tracking code to the pages on the sub domain. The tracking code for the sub domain is the same as the tracking code that goes on the primary domain (it’s the code from step 1).

3. Add Filters to Sub Domain Profiles

The next step is to add a filter to the sub domain profile so it only contains data for the appropriate sub domain. This is done using an include filter based on the hostname. Once this filter is in place you’ll have the master profile which will contain data for all sub domains, and this profile that will contain data for a specific sub domain.

Filter to create a GA sub domain profile

To create additional profiles for other domains just repeat steps 2 and 3. Obviously the settings for the filter used in step 3 will depend on the sub domain that you want to include in the profile.

Creating Additional Profiles

Let’s say you need to create a profile for two sub domains: 1.website.com and 2.website.com. This can easily be done because the same tracking code is on both sites. All you need to do is add an include filter with the following settings:

GA Filter settings for 2 sub domains.

While Google’s documentation describes a good way to track sub domains, I think this approach is better due to it’s flexibility. Plus, because the same tracking code is used all all sub domains you don’t need to worry about placing the wrong tracking code on a sub domain.

Good luck with your setup!

Subscribe:

UPDATED: GA On Site Search Setup

November 17, 2007 by Justin Cutroni

I’ve updated my post about setting up Google Analytics On Site Search Reporting. Since its launch I’ve learned a few new things and wanted to pass on the information.

For example, you can’t use filters to change the data in the reports. That’s a HUGE problem because we have no easy way to manipulate the data in the reports. Also, if you configure on site search to strip the on site search query string parameter you could artificially inflate pageviews for some pages. Now that’s trouble! You can read the complete post here:

GA On Site Search Pt. 1: Overview & Setup

If there’s anything I missed, or if you have any questions, please leave a comment.

Subscribe:

Make GA Data Quality Suck Less!

November 6, 2007 by Justin Cutroni

Frustrated with GA Data?  Get a grip!We all know that data quality sucks! But there are a few, vital steps that you can take to insure that your Google Analytics data is as accurate as possible. Remember, accurate data makes for happy, and accurate, analysts.

Here are three simple tips that can help make your data more accurate.

1. Eliminate Duplicate Data

Many sites that I work on have duplicate data. The usual cause is mixed case URLs. Google Analytics is case sensitive, it captures the data exactly as it appears in the location bar of the browser. So if a URL is of mixed case in the browser, it will be captured and displayed in mixed case within GA.

It’s very easy to have two URLs, that have the same functional meaning, appear as two line items in GA because they have a different case. Here’s an example:


/worldseries/index.php?year=2007&keyword=lowell
/Worldseries/index.php?year=2007&keyword=Lowell

Both URLs are probably the same, they just appear different because of the case. We want to force both URLs to have the same case and thus make them appear as a single line item in GA. This can be done with a Lowercase or Uppercase filter. I like the lowercase filter, but you could easily use the uppercase filter. It’s a personal preference.

The filter below will force the Request URI to lowercase:

Google Analytics Lowercase Filter

I recommend adding a case changing filter to any data element (i.e. filter field) that could be mixed case. This includes:

  • Request URI
  • Campaign Name
  • Campaign Term
  • Campaign Medium
  • Campaign Source

Another cause of duplicate data is multiple URLs that display the same content but have a different file extension. Here’s an example:


/champions/redsox.php
/champions/redsox.htm

These URLs may appear different (because of the file extension), but the web server might interpret them as the same file. Please note that not every web server behaves this way. It all depends on your web server. Check with your IT guru if your site has URLs with multiple file extensions.

You should merge duplicates URLs, that have different file extensions, into a single line item. I find the best way to do this is with an advanced filter.

Google Analytics AdVanced Filter for URI ReWrite

Some may think that a search and replace filter is the best way to remove these duplicates. But you would need to create a search and replace filter for each set of URLs that needs to be merged. An advanced filter, because it uses a regular expression, will change every URL that ends in ‘.htm’ to a ‘.php’ extension.

2. Remove Irrelevant Information

Extra information in the URL can cause big problems in Google Analytics. The reason is that GA will capture all of the data in a URL, which includes the query string parameters. Query string parameters that don’t have a functional meaning should be removed from the URL.

An easy way eliminate these parameters is to collect data for a week and then analyze the top content report. Any query string parameter that does not provide insight into what the visitor sees or does should be eliminated.

To remove a query string parameter from GA simply add it to the ‘Exclude URL Query Parameters’ field in the profile settings:

20071104-exclude-parameters.png

Enter multiple parameters as a comma separated list.

Be aware that once you remove a query string parameter from GA it is completely eliminated from the system. So any goals, funnels or other filters that use that parameter will no longer work.

Also remember that you should remove any query string parameters that contain personally identifiable information. It is against the GA terms of service to collect PII.

3. Identify Your Segment

I could have easily named this tip ‘exclude internal data’ but I wanted to change the way we all think about profiles and the data that’s in them. I believe we should think of profile data in terms of the segment we want to analyze, not who we want to exclude. I know these statements are very close in meaning, but there is a slight difference. Segmentation is so important to analysis. I believe that every time we create a profile we should consider what segment of data it will contain.

I can think if a few segments of data that I would like to analyze:

  • CPC traffic
  • New visitors
  • Return visitors
  • European visitors
  • Traffic from a specific marketing campaign
  • Non-employee traffic
  • Traffic generated by my call center

All of the above segments can be created as different profiles using include filters. Each will provide some insight into that segment. Don’t get me wrong, you’ll probably want to exclude internal traffic from 99% of your profiles. But try to think in broader terms, focus on the segment that you want to analyze.

Creating a profile based on a particular segment of traffic is pretty easy. The first thing you want to do is identify what segment of traffic you want to include in your profile. Then create a filter based on the filter filed that represents that segment.

Let’s say I want to see all traffic generated from visitors performing some type of external search on my name. I could apply the following include filter to a profile:

Google Analytics Include Filter

This filter can easily be modified to include a specific marketing campaign (using the Campaign Name field), a specific country (using the Visitor Country field) or any other segment of data so long as it is represented by one of the filter fields. Please note that this will work even if you’re using AdWords auto tagging on, even though you haven’t done any heavy lifting to define the Campaign Term.

By the way, you will want to exclude internal traffic from many profiles. My favorite way to remove internal traffic from a profile is with an ‘Exclude all traffic from an IP address’. Make sure you use anchors at the beginning and end of the regular expression.

Google Analytics Filter: Exclude IP Address

Another good way to exclude internal traffic, especially if you don’t have a static IP address, is to use a little hack called Count Me Out. This hack uses the GA custom segment cookie to identify users.

So remember, yes, you need to exclude internal traffic, but try to take a broad view and think about segmentation when you filter your profiles.

Subscribe:

New Google Analytics Features & Announcements

October 16, 2007 by Justin Cutroni

Today Google announced a number of new features for Google Analytics. I’m really excited about these features because they will greatly improve our ability to understand our site site visitors and what they want to do. You should know that this is a true beta. Google is taking signups for the new features and they should be rolled out to beta testers soon.


Links for More Information

It would be impossible to thoroughly explain each feature in a single post, so I’ve written a number of articles to cover everything you need to know.

GA.JS: New Google Analytics Tracking Code
GA On Site Search Pt. 1: Overview & Setup
GA On Site Search Pt. 2: Reporting & Usage
GA Event Tracking Pt. 1: Overview & Data Model
GA Event Tracking Pt. 2: Implementation
GA Event Tracking Pt. 3: Reporting
Urchin 6 Software
Automatic Oubound Link Tracking

New GA.JS Tracking Code

The first big change is a new version of the Google Analytics Tracking Code (GATC). The new code is object oriented, has a smaller file size and enables a number of features. The old tracking code is not going away (yet), so you don’t need to rush out and change all the tags on your pages. But you may want to given the next announcement…

Event Tracking

Google Analytics now supports Event tracking. A lot of people have been asking for it and now it exists. Google changed the GATC to enable event tracking.

You can now use Google Analytics to logically track anything, like video player interactions, visitor clicks, etc. The beauty is that you no longer need to create extra pageviews. Google has created a logical data model to help understand visitor actions and intent. I must admit, when I first heard that they were adding Event tracking to GA I was skeptical, but this feature is completely awesome! It is really well done.

Internal Site Search Reporting

The next addition is a series of reports that focus on internal site search. These reports provide a structured, logical way to evaluate the value of your onsite search. I’ve been testing these reports for a while and they are truly remarkable. I can’t tell you how much insight I’ve gained into site visitors by using them. Setup is really easy and I think everyone is going to like them. Note that the search reports are not related to, or affected by, the new tracking code.

Urchin 6 Software

And finally, Google announced a new version of Urchin software. Urchin 6 will be available in beta form starting October 22. For those of you unfamiliar with Urchin, it is a log analysis tool. You install it on your server, it crunches your log files and produces pretty graphs. Urchin 6 is a complete upgrade from Urchin 5. It has a new data processing engine and a new interface. It’s NOT using the current GA interface, it’s using the OLD GA interface. But it is a huge upgrade.

Subscribe:

GA.JS: New Google Analytics Tracking Code

October 16, 2007 by Justin Cutroni

ga.js - Google Analytics tracking codeOn October 16, 2007 Google announced a new version of the Google Analytics Tracking Code named ga.js. This means that there are now two versions of the GATC: the old urchin.js and the new ga.js. What makes the new ga.js different from urchin.js?

  • The ability to track events
  • New object oriented style; no more functions like urchinTracker()
  • Smaller size for faster downloads

This post is all about why Google introduced a new GATC, what has changed and how this is going to affect your GA implementation.

Why the Change?

Simply put, Google changed the code to support event tracking. I’m not going to focus on event tracking here, this post is just about the style and usage of the new tracking code. Please see my posts on Event tracking for more information.

Did Google need to create a new tracking code? Maybe not. But I think the modifications necessary to implement event tracking were easier using a completely new set of code rather than the old code. If you look at the entire GA system, almost every part had been re-worked since the acquisition of Urchin in 2005 except the javascript tracking code. It was time for an update and, with the addition of event tracking, the timing was right.

What Exactly has Changed?

In short, everything has changed. All of the functions that we’ve been using are now gone. Functions like urchinTracker() and __utmSetVar() no longer exist. The reason is that the new tracking code is completely object oriented. For those of you that are unfamiliar with programming styles, object oriented programming is a more modular way of creating code.

Object oriented programming does not have functions and variables, it has objects, methods and properties. Each object has an associated set of methods and an associated set of properties. Think of an object as a car. The methods are the actions that you can do with a car, like start, stop. Properties are characteristics of the car, like the color, number of doors, etc.

Details of the New Page Tag

Let’s look at the old and new code to better understand the difference. I’ve numbered the lines so I can better explain what’s going on.

Code #1: Page Tag using urchin.js:

urchin.js code

Code #2: Page tag using ga.js

ga.js code

While there are some similarities, you can see that the new code is different. Let me walk you through what it does.

The first part of the code is the reference to ga.js (line #1-#4). This is analogous to the call for urchin.js in the old code (line #1). The big change here is that the code will automatically detect if the current page is secure or non-secure (i.e. using HTTP or HTTPS). It will then dynamically request the appropriate ga.js file from the server. This is a little piece of code that was borrowed from website optimizer.

Next section of code, lines #6 - #8, is where all the work happens. First, we tell GA the account number using pageTracker._gat.__getTracker() (line #6). This is similar to setting the account number variable in the old code (line #4). Then we call the pageTracker._initData() method. This method collects information about the browser, the referral information, etc. And finally, on line #8, we call pageTracker._trackPageview(). This is the new urchinTracker(). This is how we send the data to GA and create pageviews.

The new code does the same thing as the old code, but in a very different way. Again, all of the old functions have changed and in some cases they’ve gone away. If you were using urchinTracker() to generate pageviews (like I was) then you will eventually need to replace that code with pageTracker._trackPageview().

Should you Upgrade?

This is the question that everyone is going to ask and there is no right or wrong answer. Eventually Google will kill urchin.js and you will have to change. But I don’t think that will happen for at least 18 months.

Here’s how I would approach the decision making process. First, do you absolutely need event tracking? If yes, then you should upgrade. You can read all about event tracking in this series of posts.

If you don’t need event tracking then my suggestion is to evaluate the complexity of your current GA implementation and then decide. If it’s fairly straight forward, i.e. you’re not an e-commerce site or you don’t have additional urchinTraker() calls, then I would suggest migrating.

However, if you have a complex implementation, one where you’re calling urchinTracker() a lot, you’re doing cross domain tracking, or you’ve implemented e-commerce tracking, then I would take my time. Plan your migration. There is no rush and you want to get it right.

No matter when you choose to upgrade, make sure you test your implementation before migrating. You don’t want a big hole in your data due to a mistake.

And Finally…

There is a lot more to the ga.js. As I mentioned before, all of the old functions have been replaced. I’ll have a listing of all the new methods soon. Until then, start thinking about your migration!

Subscribe: