It’s now easier to set up Google Analytics Site Search tracking for your Custom Search Engine

Cross-posted from the Google Custom Search blog

Google Analytics Site Search reports provide extensive data on how people search your site once they are already on it.  You can see initial searches, refinements, search trends, which pages they searched from, where they ended up, and conversion correlation.  In the past we admit that setup was a little challenging, but we’re happy to announce that now we’ve made it easy to setup Site Search tracking directly from your Custom Search Engine.

If you are already a Google Analytics user (and your site has the Google Analytics tracking code on its pages), go to the Custom Search Engine management page, select your CSE’s control panel and click on Google Analytics from the left-hand menu. We’ll display a list of your Google Analytics web properties so you can select one and tell us the query and category parameters that you want to track.

Once you save your changes, we’ll generate a new code snippet.  Copy it from the Get Code page, paste it into your site and setup is complete!

You can then access Site Search reports from the Content section of Google Analytics.

Happy analyzing!  If needed, you can find help with setup here and an explanation of the differences between Google Analytics and Custom Search statistics here. Let us know what you think in our discussion forum.

Posted by Zhong Wang, Software Engineer

Measuring and optimising Fairmont's social media efforts with Google Analytics

Social media is a great way for marketers to spread awareness about their products, stay in touch with and interact with their loyal customers. Barbara Pezzi, Director of Web Analytics and Search Optimization, Fairmont Raffles Hotels International, is back to share with us how Fairmont measure and analyse their social media efforts with Google Analytics. By using a combination of campaign tracking parameters and advanced segments (which can be used in combinations with social plugin analytics), Barbara is able to assess which social media campaigns work the best for generating bookings.

Update to Sessions in Google Analytics

Updated: 8/17/11 at 2:10 PM PST
Beginning today, there will be a small change in how sessions are calculated in Google Analytics. We think this update will lead to a clearer understanding of website interactions. We also want to explain how these changes might impact your reports.


What’s changing?
Currently, Google Analytics ends a session when:
  • More than 30 minutes have elapsed between pageviews for a single visitor.
  • At the end of a day.
  • When a visitor closes their browser.
If any of these events occur, then the next pageview from the visitor will start a new session.


In the new model, Google Analytics will end a session when:
  • More than 30 minutes have elapsed between pageviews for a single visitor.
  • At the end of a day.
  • When any traffic source value for the user changes. Traffic source information includes: utm_source, utm_medium, utm_term, utm_content, utm_id, utm_campaign, and gclid.
As before, if any of these events occur, then the next pageview from the user will be the start of a new session.


How will this affect my Google Analytics data?
This change only applies for visits going forward from today, and your historical data will not change. We’re bringing the definition of session in line with the common definition of a visit. If a visitor leaves your site and returns soon after with a different traffic source value, each visit will be measured with its own session.


Since Google Analytics will start new sessions for all new campaign information, sessions will now have the more accurate attribution information. This will be especially helpful if you use Multi-Channel Funnels. Additionally, by continuing a session when the user closes their browser for only a very short time, sessions will more accurately model a user’s engagement with the website. Overall, this change may slightly increase the number of visits. Based on our research, most users will see less than a 1% change.


We are excited about this update, and look forward to providing you with a better understanding of your website activity. Please leave any question about the change in the comments.


Update 8/17/2011 2:10 PM PST:
We identified an issue responsible for unexpected traffic changes following our recent update to how sessions are defined in Google Analytics. A fix was released at 2pm PST Tuesday August 16th.


The issue affected some sites using the following configurations:


1. If a user comes to a customer’s site with a space in some part of their traffic source data, then revisit the same landing page during that session by refreshing the page or later pressing the back button, a new session will be created for every hit to that page. (Clicking a link elsewhere on the site that leads back to the page should not matter.)


2. Google Analytics implementations using multiple trackers (an unsupported configuration) are also affected when a space is included in the traffic source data. These sites will see fewer visits from new visitors, and more visits from returning visitors (with some variation due to different implementations).


Again, a fix for this issue was released yesterday. Please let us know if you continue to see unexpected traffic changes. We apologize for the inconvenience and thank you for your patience and continued support.


Custom Variables: Fairmont and Swissotel use-cases

The introduction of custom variables to Google Analytics opened up many possibilities in measurement for site owners. It allows you to extend the dimensions tracked by Google Analytics to include facets that are meaningful to your business. For example, wouldn’t you like to know how your logged in members behaved differently than your casual visitors? Or which categories of content your visitors are consuming?

Barbara Pezzi, Director of Analytics and Search Optimisation, Fairmont Raffles Hotels International, has been kind enough to share her use-cases for the different types of custom variables. Head on over to the APAC Conversion Room blog to find out more about:
  • Visitor-level custom variables: Swissotel were able to segment their visitors based on membership levels, understand their preferences, and then target their marketing efforts accordingly.
  • Session-level custom variables: Fairmont measured which booking method (i.e. single vs multiple) was more popular on their booking engine; and were able to understand which method appealed to which types of customers.
  • Page-level custom variables: Swissotel used page-level custom variables to group pages according to the language of the content. With these groupings they were able to conveniently analyse the behaviour patterns and preferences of visitors according to the language of content consumed.
We would also love to hear how you use custom variables. If you have any tips or suggestions, please leave them in the comments of Barbara’s articles.

New Tools to Debug Your Tracking Code

Raise your hand if any of this sounds familiar to you:
  • You just set up your tracking code and you're wondering if it's correct--and you want to know right now.
  • You have decided to migrate your tracking to the new asynchronous syntax--but you want to know if your syntax has any errors.
  • You finally decided to customize the tracking code for cross-domain tracking--but you're worried that you might break your tracking.
  • You want to make sure that your campaign is set up to the correct goal.
Enter: The Google Analytics Tracking Code Debugger and a new debug version of our JavaScript code.

The Google Analytics team has launched a debugging version of the Analytics Tracking code called ga_debug.js to verify your tracking code setup. To make it even simpler, we also created a Chrome extension which uses the ga_debug.js script, which allows you to use the new ga_debug.js without re-tagagging any of your content. You can also use this extension to verify what information is sent to Analytics with each page.

How does it work? First, the ga_debug.js script provides a testing version of the tracking code which will print common syntax errors and tracking analysis messages to the browser’s JavaScript console. Secondly, the Chrome extension which automatically enables your page to use the debug version of the JavaScript without any need for you to retag or recode your pages.

How do you use it? The most simple thing to do is to download the Tracking Code Debugger extension for your Chrome browser. Next, turn on the extension by clicking on the icon to the right of the address bar on Chrome.

Finally, visit a page that contains the tracking code you want to test and open up the Chrome JavaScript console to see the messages (detailed instructions). That's it!

If you want to go use ga_debug.js without the Chrome extension, read all about how to do this in our newly revised Troubleshooting Guide on Google Code. You can use the script on your testing environment to verify extensive tracking code changes. Make sure, however, that you don't use this version of the tracking code on your production website--the script is meant for debugging and analysis, not speed, so you should always use this as a testing mechanism only. If you want to learn more about the kinds of errors this script can help you find, see Common Tracking Code Errors/Typos in our Troubleshooting Guide. While the ga_debug.js script doesn’t catch all possible errors yet, we think it’s off to a great start and will get even better over time.

Happy testing!

Brian Kuhn on behalf of the Analytics Team

Making the Web Faster

Today, our web search team announced how Google search now uses site speed as a factor in ranking. All things being equal, a faster loading site is better than a slower site.

With this announcement, we wanted to remind you about Google Analytics asynchronous tracking. The asynchronous tracking code has a faster load time and can improve site speed, especially on rich-media or script-heavy pages.

We encourage users to update to the asynchronous snippet to help make your site and the web faster. You can read up on how to implement the asynchronous snippet on our Google Code site. We also have a comprehensive list of migration examples to help you make the switch.

Google Analytics launches asynchronous tracking

Google Analytics now provides a new Asynchronous Tracking Code snippet as an alternate way to track your website!

Think of the asynchronous tracking code snippet as a script that uses a "separate lane" to handle part of the processing of your webpage. As the number of cars (or in this case, scripts on your webpage) increases, the asynchronous tracker uses this lane to reduce webpage load time. Websites that use many scripts or rely on rich media content will especially benefit from this new method, but even lightweight sites will see improvements.

The new tracking snippet offers the following benefits:
  • Faster tracking code load times for your web pages due to improved browser execution
  • Enhanced data collection and accuracy
  • Elimination of tracking errors from dependencies when the JavaScript hasn't fully loaded
The asynchronous tracking code is now in Beta and available to all Google Analytics users. Using the new tracking code is optional: your existing Google Analytics code will continue to work as-is. But if you want to improve your webpage load times and fine-tune the accuracy of your Analytics data, then we think you'll love this new option.

Learn more about this new tracking code on our Analytics Help Center and get started on Google Code.

Posted by Jesse Savage, Google Analytics Team

Segment your Traffic with the User Defined Report

Have you ever been in the Visitors section of your favorite Google Analytics profile and wondered what the heck “User-Defined” was? Well today it's time to find out.

So, what is “User-Defined?"

The user defined variable allows you to "label" a visitor if they complete a certain action on your site, such as making a purchase or visiting a key page. These labels are useful because they last across multiple visits to your site.

These labels are often called Custom Segments (or Custom Segmentation). You can see the data from these Custom Segments in the User Defined report, which is the last report of the Visitors section in Google Analytics.

How do I add these “labels” to my website visitors?

Making use of the User-Defined report in Google Analytics requires a bit of extra coding help from your IT department or webmaster, but it’s often well worth the effort.

For example, let’s say that I want to add a label of “customers” to any visitor who reaches my shopping cart’s receipt page. In order to do this, I would add an additional line of code to the Google Analytics Tracking Code (GATC) on my receipt page. It would then look something like this:

<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-XXXXXXX-1"); pageTracker._trackPageview(); pageTracker._setVar(”customers”); } catch(err) {}</script>

Notice the line in bold that includes _setVar. When this is present on a page within the Google Analytics Tracking Code, an additional cookie (called the __utmv cookie) gets set on a visitor’s computer, with its sole purpose being to identify the visitor by the label (or value) that you used in the code. If you take a look at the code example above, you will see that I used the termcustomers,“ the label that I want to appear in the User Defined report.

Now, on their next visit to the site, they will be identified as a part of the “customers” segment in the User Defined report, allowing you to perform analysis on all visitors who have purchased something from your online store. Neat, huh?

Can I use _setVar when someone clicks on a link instead of visiting a page?

Yes - you can also use the pageTracker._setVar function when someone clicks on an important link on your site, or makes a key selection on an important form that you want visitors to fill out. For example, if you wanted to add a custom label to any visitor who clicks on your “Live Help” applet, you can ask your IT department or webmaster to add an “onClick” event, and give them the following line of code:

onClick="pageTracker._setVar('Needs Help');"

What will this look like in the end?

When all of your coding is complete, check the User Defined report after about a day or so and you should see something like this:

After the data has been collected by Google Analytics, you can interact with it just like you would with any other report. Click on the “Goal Conversion” tab directly above the table to see how many customers have reached key pages of your site, or use the dimensioning feature to see what sources of traffic were responsible for bringing these special visitors to your website!

Are there any other ways to use _setVar?

One neat usage of the _setVar function is to use it to exclude your own traffic from reports when using a dynamic IP address. For example, let’s say that you wanted to exclude your entire company’s traffic from appearing in reports, and your company uses dynamic IP addresses.

Because it would be nearly impossible to write a filter to exclude traffic from a dynamic IP address, you can create an HTML page that is not a part of your website and add Google Analytics Tracking Code with the call to _setVar and a label of “employees” (or something similar).

Next, you can ask each employee to visit that page from their browser of choice – this will drop a cookie on their computer, identifying them as “employees.” Finally, you can then apply a filter with the following specifications to your profile, and your internal traffic will be excluded:

  • Filter Type: Custom Filter >> Exclude
  • Filter Field: User Defined
  • Filter Pattern: employees
  • Case Sensitive: No

Some technical notes about Custom Segmentation:

  1. As we just talked about, when a person visits a page calling the _setVar function, the __utmv cookie is set on their computer. This is a persistent, first-party cookie that has a lifetime of two years. This means that every time a user with a __utmv cookie returns to your site, the label assigned to the user will continue to identify them as such until they either delete the cookie or visit another page with another call to _setVar with a different label.

  2. The purpose behind something like a User-Defined report - and Custom Segmentation in general - is that it is not designed to be updated very often. This label, for the most part, should be a permanent one for a visitor. You should only use _setVar on pages like a receipt page of a shopping cart, or an account registration “success” page for a visitor who becomes a member of your site. You shouldn’t use _setVar on your homepage, or use several different _setVar’s with different labels scattered across many pages of your website.

  3. Google Analytics - at this time - only has the capacity to store one custom segment at any one time for one website. So if you are using multiple calls to _setVar on your site, Google Analytics can only store the latest value that a visitor runs into in the __utmv cookie. John Henson at LunaMetrics – a fellow Google Analytics Authorized Consultant - has created a custom version of the Google Analytics Tracking Code that can support multiple custom segment labels at any one time.

  4. On the other hand, Google Analytics uses what they call the “first association” of the session for visitor session calculations. If you are using multiple calls to _setVar on your site, be aware that if a user runs into the first one, and then runs into the second one in the same visit, their Goal Conversion and Pages per Visit metrics would be attributed to the label of the first encounter with _setVar.

  5. For page view calculations, Google Analytics uses the most recently defined value. So if a person runs into the second instance of _setVar on your site, all of their pageviews afterwards - including the current pageview - will be attributed to the second _setVar’s label, even though as we just learned in #4 above, visitor session information is attributed to the first encounter of _setVar.

A full, technical explanation of _setVar and the User-Defined Report can be found here.

Summary

The User Defined report in Google Analytics is a great place to start segmenting your traffic. With a little bit of help from your IT department, you can not only begin to collect awesome data, but you can also begin to gain advanced knowledge about what makes your VIP website visitors register, sign-up for your newsletter, or purchase something from your online store. This will definitely help you become that Analysis Ninja that Avinash Kaushik loves to talk about!

Written by Joe Teixeira of MoreVisibility, a Google Analytics Authorized Consultant.