412.343.3692
1.800.975.1844

Archive for the ‘Google Analytics’ Category

Stuff More Than One Value into GA’s User Defined Segment

Thursday, April 17th, 2008

The User Defined Segment Variable in Google Analytics allows us to give each visitor to a site a distinctive label. Member or Non-member, Male or Female, Large or Small. This value is then stored in a cookie called __utmv on the visitors computer. Each time the visitor comes to your site, the Tracking Code checks for a value in that cookie and sends it along with the rest of the data.

The More-Than-One-Value Problem

But sometimes you would like to keep track more than one piece of information in GA’s User Defined Segment. You might want to know when you have a Small Female Non-member or a Large Male Member.

Most of you already know that Google Analytics only gives us one User Defined Variable. At first glance, that isn’t an issue, we can just set our variable to ‘Small/Female’ and now we have more than once piece of information about that visitor, right?

But you don’t always learn every piece of information at the same time. And whenever you set the value of the variable, it overwrites the previous value.

Here is a technique (and the JavaScript) that I have used when I’ve needed to overcome this particular limitation.

How it Works

With the old version of the Tracking Code using urchin.js, we set the variable with:

_utmSetVar('someValue');

And in the new version using ga.js:

pageTracker._setVar('someValue');

But instead of using those, we’re going to use a new function:

superSetVar('someValue');

This function will check to see if the visitor already has ’someValue’ assigned. If the value is already there, the function doesn’t do anything. But if it is not there, it adds this value to the end.

For example, if we set two values in a row with superSetVar:

superSetVar('/eyes=blue');
superSetVar('/hair=blonde');

instead of the second value overwriting the first, and making the User Defined Segment Variable equal to ‘/hair=blonde’, with superSetVar it is equal to ‘/eyes=blue/hair=blonde’.

In this way, we can use the superSetVar function whenever we need to add a piece of information to the User Defined Segment Variable in the __utmv cookie, and each time, the new value gets added to the end.

Naming Conventions

This brings us to some naming conventions. You’ll notice that I’m using the format /name=value for my variables. Aside from helping us visually in the GA reporting interface, and giving us a little something extra to work with when setting up filters, it also assists us in our next task - unsetting a value.
[This naming convention is required in order for everything to work as advertised. However, feel free to alter the code within the super_set_var.js to suit your own needs.]
With the original GA functions, we don’t need to unset our variable, since every time we set a value, it overwrites the previous value — a sort-of built-in unset. So if you have a value of NonMember and later become a Member, the NonMember values gets overwritten and you just end up with ‘Member’. But if you used superSetVar you would end up with something like /status=nonmember/status=member.
Because of this we need to have another function, unSetVar. You could use it like this:

unSetVar('/status=');
superSetVar('/status=member');

The unSetVar finds any instance of ‘/status=something’ and deletes it. So if you wanted to change someone’s eye color:

unSetVar('/eyes='); // clears all /eyes=someColor
superSetVar('/eyes=green'); // adds '/eyes=green' to the end of the __utmv cookie

What value will show up in the reporting interface?
Sometimes figuring out what you’re going to see in the reporting interface is a little tricky. With this method of setting the User Segment Variable, it should work like this:
If the visitor does not have a value already defined, then the first value that you give them will be used.
This means that if you call superSetVar multiple times, the latter values won’t show up, until the user comes back for another session.
However, if the visitor already has a value for the User Defined Segment Variable when they arrive at your site, then that value will be used. If you set additional values, they won’t show up in the GA Reporting Interface until the users next session.

Implementation:

1. Download super_set_var.js

2. Copy it to your web server.

3a. For the new version of the GATC, add the line in bold to your GATC after the call to ga.js, making sure to change the /path/to/super_set_var.js to the location on your webserver where you put that file in step 2:
<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” src=”/path/to/super_set_var.js”></script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-xxxx-y”);
. . .
</script>

3b. For the old version of the GATC:
<script src="http://www.google-analytics.com/urchin.js"
type="text/javascript"></script>
<script type=”text/javascript” src=”/path/to/super_set_var.js”></script>
<script type=”text/javascript”>
_uacct = “UA-12345-1″;
. . .
</script>

4. Use superSetVar(”/someName=someValue”); wherever you would have used pageTracker._setVar(”someValue”); or _utmSetVar(”someValue”);

Technical Note:
This implementation chooses to set the __utmv cookie with a pageTracker._setVar(’…’); that is associated with a ‘fake’ UA number. You could instead choose to alter the code to write the cookie by hand, or to use a _setVar(’…’); that is associated with the actual UA number for the account.

If you have any comments, improvements, alternatives, etc, please post them below. I’m sure some of you have had the opportunity to do this before, so share any pitfalls you’ve encountered or just tell me why your method is better than mine.

-John

Google Analytics: Worst Titles Ever

Saturday, April 12th, 2008

“Remember,” John McAndrew cautioned as we started a new project for the Association of Corporate Counsel, “The GA titles are deadly.”

This is so true. As much as I love Google Analytics, their report titles and labels just suck. (I hope you guys are listening.)

There are a lot of things GA does right. But if we are going to have an analytics package that is “democratic” — that all the people in the company can use, not just the Web Analyst — we need to have descriptive titles and labels. And they need to be things that the average Joe and Jane can understand. And we have to stop calling the same thing by different words in different places. (If we are going to call paid search “cpc” on the medium report, why do we have “paid” and “unpaid” in another?) Or as one person said to me in the all-day training I did on Monday, “That’s just Google Analytics’ way of tripping us up, right?” And, the sad part was: he was right.

(Here is a little more full disclosure, or maybe credit where credit is due. Back when LunaMetrics became a Google Analytic Authorized Consultant, I started bitching about the GA documentation, for the same reason. “If we have an analytics package for regular people,” I argued, “Shouldn’t we have drop-dead, knock-your-socks off documentation? The kind that everyday people can understand?” And since that time, we are getting there, thanks to Brett and Alden and a lot of other people whose names I don’t know. So all things are possible.)

OK, let’s roll up our sleeves, and just address the Seven Deadly Names and Titles. In reverse order, so that they get worse and worse…

DeadHostname vs Network Locationly Title #7: Network Location vs Hostnames. Some way, we have got to figure out how to indicate that “network location” is the visitor’s ISP and “hostname” is all the URLs that your site goes by in GA. So, for example, “Hostnames” is the report to go to when you want to know if you have subdomains setting cookies, or if some other site has stolen your code and uses it to muddy your analytics. On the other hand, Network Location is the place to go to when you think you might be able to learn what company the visitor came from. (This last part generally only works if the visitor came from a big company, like Toyota or GM, who is their own ISP.)

Deadly Title #6: Top Content. It is ALL content, not just top content.

Deadly Title #5: CPC vs Paid; Organic vs Unpaid. I would love to say, “Can’t we just go with one or the other? Let’s just call it paid search and unpaid search and forget the other stuff here.” Reality is not so easy, though, because this one is not just about titles, it is about cookies. To get less technical than that — this door of opportunity closed years ago. We just have to live with this one, and always remember that cpc means paid search, and organic means unpaid search.

Deadly Title #4: Visitor Loyalty. We have a set of reports called Visitor Loyalty, and then under that we have a specific report called Loyalty, too. So can’t we call the whole set Visitor Loyalty, and then call the report itself Frequency? Because that is what it measures, how many times they came.

Deadly Title #3: Navigation Summary: How visitors found your content. (I am only explaining/complaining about the subtitle, “How visitors found your content.”) This report describes how visitors got from one place on your site to the page you are interested in and where they went next, and NOT how they found your content from outside of your site. “Paths visitors used to get to and from your content” might be a little better.navigation summary

Deadly Title #2: Entrance Paths: Paths visitors used to get to your content. Well, that is just ridiculous, this subtitle is perfect, but it belongs on the Navigation Summary report (Deadly Title #3), not here in Entrance Paths. If you look at an Entrance Paths report, it starts out with *your* content and shows where they went next. In fact, this particular Deadly Title gets an extra point for deadliness, because this isn’t really about Entrance Paths at all: the page you are interested in might not be an entrance page. This is a report about where the visitor went after they looked at your page.

Entrance paths

The Winner!! Deadly Title #1: “Most people visited…” This is arguable the worst label we have in GA. Here you can see it:

most people visited

It is misleading in more than one way (which is why it scored for Deadliest Title.) As I pointed out when I did my loyalty experiments, this set of charts measures visits, not visitors. But using the word “people” gives the impression that it is the other way around.

Even if we pretend that the chart says, “Most visits happened only once,” or some other way to get rid of the word “people,” it would still be misleading. “Most” just describes the bar that is the longest. And it completely obscures how great that chart can be — we have an incredible report that puts visits into buckets of frequency, and then we dumb it down by saying, “Just look at the longest one.”

Robbin

Are your Top Content URLs Too Long?

Thursday, April 3rd, 2008

Google Analytics’ reporting interface often can’t display the entire URL for a pageview in the Top Content report.

Most browsers support the ability to override a web page’s CSS with a custom .css file. Here is how to use that feature in Firefox to let you see the full URL string.

(If you use IE, Opera, Safari, etc, just show this article to your favorite geek, and if you’ve been nice to them, they might help you out.)

The key is the userContent.css file. CSS placed in this file can override a page’s default CSS. This file resides in your /chrome directory. On my Windows XP computer, it is:

C:\Documents and Settings\Henson\Application Data\Mozilla\Firefox\Profiles\722qaf8f.default\chrome\userContent.css

If the file does not already exist, just create it in a text editor.

Add the following CSS to the userContent.css file to alter the display behavior in the GA reporting interface.


@-moz-document url-prefix(https://www.google.com/analytics/reporting/top_content)
{
.records td {
padding: .4em !important;
padding-bottom: 2.0em !important;
vertical-align: top !important;
}
.text_wrapper {
white-space: normal !important;
}
.text_wrapper .text_wrapper {
white-space: normal !important;
overflow: visible !important;
}
a { white-space: nowrap !important; }
}

And what do you get for your effort?

Top Content - Google Analytics

But John, that’s so much work!

If you don’t like working with userContent.css, try the Firefox extension Stylish:
https://addons.mozilla.org/en-US/firefox/addon/2108
Install. Select Write Style > Blank Style (from the status bar icon) and Paste in the above CSS.

Bonus: Per-site user stylesheet rules:
http://lists.w3.org/Archives/Public/www-style/2004Aug/0135.html

Happy Reporting,

John Henson

Google Analytics and the John/Avinash Show

Wednesday, March 19th, 2008

Wow, did you all see John Marshall’s dreamy new look in the five videos he and Avinash Kaushik created? John, you look awesome with contact lenses. BTW, if people didn’t see the blogpost or the videos, they were all about which referrer gets credit for a conversion when the visitor has looked at multiple sources before converting, and/or cleared cookies — a really great topic.

You may not have seen them for the same reason that I put this off for a full week: I am not a video fan. Sure, I do them when I have to, or when it is hard to understand something. But I am always dying to read - I feel like I can read 40 minutes of video in about 5-6 minutes. The question is always, will I come away with as great of an understanding?

I am probably the next-to-last person in the universe who would rather read than watch, so for that last person, here is a synopsis. I have also embedded the Google Analytics interpretations where that makes sense. Suggested reading time: 5.5 minutes.

Act I, whereby Avinash and John explain who gets credit for the sale with only one referrer. This was an easy situation: A visitor is looking a
the NYTimes online, clicks on a banner ad hosted by Doubleclick, goes to the site and purchases. If the Doubleclick ad is correctly tagged and all the pages on the site are correctly tagged, Doubleclick will get credit for the sale. This is true for all analytics packages, including GA.

Act II, whereby Avinash and John explain who gets credit for the sale with multiple referrers. This was a harder situation. Everything is correctly tagged. The visitor starts with the same NYTimes ad hosted by Doubleclick, he looks at a few pages, but doesn’t purchase. He comes back a second time using a paid search ad, and he looks at a few more pages. However, he still doesn’t purchase; instead, he bookmarks the product of interest. The third time, he uses his bookmark to come back and he purchases. Now, who gets credit for the sale? John and Avinash said, “Your analytics package will usually give credit to the last referrer, direct (none).” This might be true for many analytics packages, but I know it is not true for Google Analytics. In GA, a referrer always overwrites the last referrer, with one exception: direct (none) will never overwrite, or if you like, override, a prior referrer. It is possible in GA to avoid overrides/overwrites, but it is not possible to force GA to give credit to the bookmark. So to summarize: if someone comes on a banner ad, comes back on PPC, and finally converts using a bookmark, GA will not give credit to the bookmark — it will give credit to the last “real” referrer, which in this instance is a search engine’s paid ad. (John Marshall discussed this with me, and he pointed out that it is not clear that the way GA does it is the “right” way. This is arguable, but we weren’t go there now.)

Act III, whereby John and Avinash point out why all those different measuring tools you have show different results. Ok, we understand how your web analytics tool works, now, especially if it is Google Analytics. But what about all those other measurement packages you have? How does your DoubleClick report work, how does your paid search report work? After all, that person started with a DoubleClick ad, came back with a paid search ad, and converted on a bookmark. Well, strangely enough, everyone gives credit to themselves! Doubleclick takes all the credit for the sale, as does the paid search conversion tracking when you look at it using a tool like the conversion tracking that comes with Google AdWords or Yahoo Sponsored search.

So, (Act IV) John said, this is a great reason to use your web analytics to look at Time On Site - even though your analytics doesn’t give credit to all referrers, you can use Time on Site to understand how important those referrers might be.

Time on SiteHmmm. How would we do that with Google Analytics? The best way would be to create a special profile for each important campaign. Then you’d be able to use the time on site and depth of visit charts (under Visitors > Visitor Loyalty) to get a “bucketed” understanding of how many people referred by DoubleClick stayed for 3 minutes, 4 minutes, etc. Of course, you’ll still want to drill down to the adGroup and keyword level, and there you will only be able to look at averages, but it is better than nothing. And if you have one really important keyword, go ahead! create a profile for it.

Act V: Whereby John and Avinash discuss what happens when cookies get deleted, or privacy tools block cookies, etc. Doubleclick gets deleted, usually. Even your PPC tool’s cookie usually gets deleted. So by the time the sale happens, there really *aren’t* any cookies to take credit for the sale! And this is quite a wonderful revelation in my eyes, because now it explains why so many accounts have a potentially disproportionate amount of traffic in “direct”, even when all campaigns are coded correctly. In this situation - no cookies left to take credit - even Google Analytics will give credit to the sale to direct (none.)

Robbin

Basic Segmentation with Profiles in GA

Monday, February 25th, 2008

I often see accounts set up in Google Analytics with only a single profile. This is really a shame. There is a lot of great information that is obscured with just a single, overall profile.

There are a several reports and metrics that you can’t segment within the Google Analytics reporting interface, such as

1. Funnel Visualization (Goals > Funnel Visualization)

2. Visitor Loyalty Reports (Visitors > Visitor Loyalty)

3. Ecommerce Reports

4. Number of Visitors

These are much more interesting (and useful) when you can compare them against different segments of your traffic or see trends within just one segment.

Funnel Visualization, for example, is a great report. You can see where visitors drop out of your funnel and where they go when they leave. But you can’t compare funnel behavior for New Visitors and Returning Visitors.


If you could look at them separately you would be able to tell that the change to your website that caused an increase in funnel exits is only affecting Returning Visitors. Maybe you moved a vital element to a different area of the page. There isn’t anything wrong with the new placement (New Visitors are doing just fine), except that your Returning Visitors are expecting it to be somewhere else.

But you don’t know any of that because you can’t look at the Funnel Visualization report by Visitor Type.

Or Can You?

By creating some extra profiles you will be able to isolate which group of visitors is responsible for the changes you see in your data.

Here are a few basic profiles you can use to look at segments of your website traffic separately. (Each of these links to an image showing the filter that you need to add to that profile.)addwebsiteprofile.jpg

Only Direct Traffic

Only Organic Traffic

Only Paid Search Traffic

Only New Visitors

Only Returning Visitors

 

 

Creating Profiles

1. Click Add Website Profile

2. Select Existing Domain, Name Your Profile, Finishcreatenewprofile2.jpg

3. Select Edit for the new profile, then Add Filter

4. Create the filter shown in the Links above for the profile you just created, click Finish

 

 

 

 

addfilter.jpg

With these profiles you can compare your funnels for New vs Returning Visitors or your ecommerce reports for Organic vs Paid Search. Use your Organic profile to see if your SEO efforts are paying off, or your Paid Search profile to refine your pay-per-click campaigns.

Every time you are looking at Google Analytics and wish you could segment that report just one more level, you may have found another opportunity to create some extra profiles.

-John

Extending User Defined Segmentation in GA

Monday, February 18th, 2008

The user defined segment in Google Analytics is a very underused feature. But those that do use it, are often
frustrated because you can only use it once on a site. However, there are situations where it can be safely and easily
used for multiple purposes. Here is a situation I encounted that makes an excellent example. It uses some
JavaScript to determine if the User Defined Segment Variable (_utmv) is already being used and decides what to do accordingly.

Quick Refresher:

The user defined segment based on the value of the _utmv cookie.
You set the value of this cookie with the __utmSetVar() function in urchin.js or with pageTracker._setVar() if using ga.js.
To view the user defined segment in your analytics, go to >Visitors->User Defined.

Background:

You currently use the _utmv cookie to segment your employees’ actions from other visitors, as well as exclude them from certain profiles.
For our example, we set the emplyee’s cookie value to “notrack”.
(Justin Cutroni has a great post explaining what this is and how to do it.)

Now, you want to track your members separately from other visitors. You’ve configured your login page to set the _utmv
cookie to “member” upon successful authentication. Now, they’ll be tracked as a part of the “member” segment for any pages they view.

The Problem:

The problem is that once your employees log in, their “notrack” cookie is overwritten with the “member” cookie.
On their next visit, it’ll look like they’re a regular member. (We don’t want that.)

The Solution:

With a tiny bit of JavaScript, we can easily keep the “member” cookie from overwriting
the “notrack” cookie when an employee logs in.

To set the _utmv cookie, we would normally just place the code below on the landing page after the user logs in.

- urchin.js

<body onload="javascript:__utmSetVar('member');">

- ga.js

<body onload="javascript:pageTracker._setVar('member');">

However, this would overwrite any _utmv cookie that was previously set. (ie, our “notrack” cookie)

We just need to add a short JavaScript function to see if the cookie already exists, and update our
onload event to call the new function instead of __utmSetVar.


    <script type="text/javascript">
    //<![CDATA[
    function tagMembers()
    {
    var allcookies = document.cookie;
    var mycookie = allcookies.indexOf("__utmv");
        if (mycookie == -1)
            {
                    __utmSetVar('member');
            }
    }
    //]]>
    </script>

* For ga.js, just replace “__utmSetVar(’member’);” with “pageTracker._setVar(’member’);”.

Your body onload event should now look like the example below:

<body onload="tagMembers();">

What does it do?

Instead of automatically setting the _utmv cookie every time, we check
to see if the cookie is already set. (It doesn’t matter what it’s set to. If it’s “member” already, we don’t need to set it again, and
if it’s “notrack” we don’t want to set it again.

Now, when your employees log into your site, they’ll continue to be tracked or excluded as such.

I hope this helps to expand everyone’s use of the _utmv cookie. With a little logic, you don’t need to be bound
to using the _utmv cookie for only one type of user. I welcome your questions, comments, and suggestions.

Coming soon…Adding logic based on the actual value of the _utmv cookie.

Copying Goals in Google Analytics (A Firefox Extension)

Monday, January 21st, 2008

Ever need 30 profiles, each with the same 4 goals? Me too. Unfortunately, Google Analytics doesn’t include an easy way to manage goals.

So, here’s the Firefox extension I created to speed up the process of copying goals. We’ll just call it “GoalCopy”.

What it doesGoal Form Fields

The Goal Copy extension records all of the values in a Google Analytics Goal Settings form. You can then navigate to another profile where you want to put that copied goal and paste all of those values into the new form. That way, you can get your goals from one profile to another without all the tedium.

When you install it, it will create a new toolbar with 4 sets of copy/paste buttons. Each set will copy and paste a different goal of your choice. The toolbar can be toggled on/off with View -> Toolbars -> GA GoalCopy

How to use it

1. After installation, navigate your Firefox browser to an existing Google Analytics Goal Settings form.

2. Click one of the four Copy Goal buttons on the Goal Copy toolbar.

GoalCopy Toolbar

3. The name of the Paste Goal button will change to show the name of the goal you copied. If the name of yourGoalCopy Paste Button goal was “Subscribe to Newsletter” then the Paste Goal button will display “Paste: Subscribe to Newsletter”

4. Go to another profile and navigate to a Goal Settings form page where you’d like to use your newly copied goal.

5. Click the Paste button to populate the new goal form with the values from copied goal.

6. Remember to scroll down and click “Save Changes” on the form.

That’s it. You now have your new profile ready to collect goal conversion data.

Notes

Buttons are grayed-out when not on a Goal Settings page.

There are 4 Slots to save goals in. Each set of Copy/Paste buttons uses its own slot.

Clicking Copy Goal again overwrites the previously saved goal for that slot.

Goals are saved persistently. Closing your browser does not erase your saved goals.

When clicking from a tab that is still Loading to a Goal Settings tab, the buttons will not re-enable properly from their grayed-out state – just click on a tab that is fully loaded (or blank) and then back to the Goal Settings tab to enable the buttons.

Requires Firefox 2.0.*

Thanks

Thanks to everyone who provided testing and feedback, including Jason Green here at LunaMetrics, Justin Cutroni at EpikOne, Shawn Purtell at ROI Revolution, and Mike Plummer at POP (sorry for not getting it out earlier that day, Mike).Install Dialog

Installation

Open this link in Firefox

Then click Install Now.

Depending on your setup, Firefox may want to download the file instead of installing it directly. Just select “Open With. . .” and choose Firefox from the list of applications.

Alternate Version

If you’re having problems with the toolbar being greyed-out on the ‘Edit Goals’ form page, try this version that never disables the toolbar buttons.

These changes have been incorporated into the latest version and are part of the goalcopy.xpi file.

-John Henson

Getting More than One Requirement out of your GA Report Filter

Wednesday, January 16th, 2008

The Problem

Do you sometimes want a second report filter at the bottom of your keyword reports?

Report Filter

I do. Every time I want to see phrases containing a particular word, but not containing branded keywords. For example, I might want to see all searches containing “conversion”, but not “lunametrics conversion.” It is a recurring theme for me.

 

The Solution

So what do you do? It’s called a Lookahead, and it comes in two versions. Positive Lookahead and Negative Lookahead. And we can chain together as many as we want.

Let’s say I want to find all keyword phrases that contain conversion and contain website but do not contain lunametrics. Here is what I’d type into the report filter:

^ (?=.*conversion)(?=.*website) (?!.*lunametrics).*$

The (?! begins a negative lookahead (must not match) and a (?= begins a positive lookahead (must match). The regular expressions inside the lookaheads can be as complex as you want. But if you just want to follow the formula I used here. . .

 

The Recipe

1. Start with ^
2. Place each word you don’t want inside a Negative Lookahead : (?!.*word)
3. Place each word you do want inside a Positive Lookahead: (?=.*word)
4. Chain together as many of each as you want
5. Finish up with .*$

Caveat

This example will match anything with “website” in it anywhere. If you want to match exactly “website” and not “websites” or “123website”, use (?=.*\bwebsite\b) instead.

Keyword Analysis by Number of Terms (and the RegEx that helps)

Wednesday, January 2nd, 2008

Do long search phrases convert better?

This was what I wanted to find out for a particular client, but it took some work. I used a regular expression in the Keywords Report of Google Analytics to filter by the number of terms in the Keyword Phrase. The exported results showed a clear increase in conversion rate as the number of search terms increased.

This client was doing far better with searchers who were using a lot of terms. They were being specific! They knew just what they were looking for and were ready to buy. This data put additional power behind recommendations concerning content, search engine optimization and paid search strategies.

1 .59%

2 .60%

3 .90%

4 1.17%

5 1.06%

6 1.22%

7 1.88%

8 3.33%

 

 

Even though there were a lot of people using long search phrases, this data was obscured. As the number of terms increased, the number of people searching for exactly that phrase decreased. This resulted in none of the individual phrases seeming to count for much. The so-called Long Tail.

You really have to dig to find these sorts of gems but they are invaluable in the pursuit of providing information that can be acted upon.

A tool for digging

The tool is a Regular Expression, a pattern matching language. If you’re not already familiar with it, there is a great series of articles right here on the LunaMetrics blog.

Here is what I used:

^([\\+*"*\\s*,*'*\\-*]*\\w+\\b\\s*[\\+*"*\\s*,*'*\\-*]*){3}$

It accounts for the most common characters I’ve found between words.

Steve (see comments) pointed out a great way to shorten my expression by using the \W character set. Here is what it looks like.

^(\\W*\\w+\\b\\W*){3}$

\W is shorthand for all non-word characters

How do I use it?

How_to_use_it

I know this may look like gibberish but keep reading — you don’t need to understand it to get some use from it.

In Google Analytics, go to Traffic Sources > Keywords and paste the Regular Expression into the box at the bottom of the data. Just change the {3} to whatever number of terms you want to see and click the GO button.

A brief look at the RegEx

Although this is not strictly a Regular Expression post, I feel obligated to include a basic glance at the different parts of the expression. Feel free to skip this if you just don’t care.

^ anchors the beginning of the match to the beginning of the string

( ) used to group a set of items together for a match

[\+*"*\s*,*'*\-*]* This group matches any number and any order of + ” , – ‘ and whitepace (\s). It is what handles all the characters that might end up separating different search terms.

\w+ Matches 1 or more alphanumeric characters (the \w is another pre-defined set of characters like \s)

\b Match for a word boundary. It forces the \w characters to be separated by something. Otherwise the expression will match any string of characters longer than {3}.

{3} Requires exactly 3 of the above sequence so it would match the phrase one two three but not one two three four

$ anchors the end of the match to the end of the string

 

Don’t Sweat the Small Stuff

You can’t account for every situation. For example, sometimes ‘ is meant as an apostrophe and sometimes “-” is used as a hyphen. In the end the impact is usually small – just 2-3% of the search phrases were affected in my case and they just get bumped to the next higher match instead. (For example, non-glare window would match at {3} instead of {2})

It is an interesting way to look at keyword data and maybe you’ll get some use from it– if you do, let me know.

 

More on GA Visitor Loyalty (and unique visitors)

Saturday, December 29th, 2007

Can you combine your unique visitor numbers and your visitor loyalty numbers (in GA) to learn more about returning visitors?

That was ultimately the question that faced me when I sat down at my computer today. A few weeks ago, I wrote about GA Visitor Loyalty, and today, read this comment/question from a reader:

I looked at the following:

Unique Visitors (39811 for the last month on my site))
minus
# of 1 times visits (37037)

Wouldn’t this mean that about 2800 different people visited my site more than once?

But no …

For this year, I had 306,810 unique visitors and 305,025 # of 1 times visits. Following my above logic, only 1800 visited my site more than once for the year, but 2800 did so for the month.

Any explanations?

So here is my answer, for this reader, and for anyone else who is interested:

Let’s start with your first question: If you take unique visitors and subtract the one time visits from that, won’t the difference be about equal to the number of people who visited your site more than once in the period?

Answer: No, it won’t. In fact, to make this easier, let’s reformulate the question: Why aren’t unique visitors in the period equivalent to one time visits?

“Unique visitors” measures how many times unique browsers (and we will just call them “people”) visited in a specific time period. But the Visitor Loyalty does something different. It says, “For every visit during this period, tell me the visit history for ALL TIME.” So the first time that I did the testing in this post (the testing that ensured I was the only visitor), I visited once, I went back the next day, and I was shocked to see that in the Visitor Loyalty chart, there was only one visit (no surprise there) and it was in the 201+ visits category (that was the shock.)

Unique visits for any time period are sprinkled throughout the chart. Maybe they visited once this month, but last year, they visited 35 times, and so this one visit, unique this month, or unique this year, is their 36th.

Ultimately, the Loyalty Chart is the wrong place to do this work — you need filters to include just returning visitors, or a filter to exclude new visitors. You might create a new profile with an exclude filter on “Visitor Type” and use the word new– that way, you will only get returning visitors in your profile. And then you can start to learn more. (Need to learn more about creating custom filters?)

- Robbin