You are here: Home

Text functions: mid

by Jared Huber on May 12, 2010

If the only tool you have is a hammer, every problem starts to look like a nail. Sure, there are better tools for text splitting and string parsing for people with some programming expertise, but Excel usually acts as the default analysis and data manipulation for most analysts (including myself!) As a quick and dirty analysis and text processing tool, it does ok; the intent of this post is to walk you through some of the most common text functions within excel, and provide some examples of how I’ve used them in a PPC, SEO, and Web analytics context.

The data I’m working with in this example are full referral URLs from Google Analytics, populated into the user defined variable using an Advanced Custom Filter. Referral URLs are particularly pesky to analyze because there’s a lot going on within each. Let’s break them down into more manageable pieces using mid. Here’s what the URLs look like from GA.

Referral URL Strings from GA

Referral URL Strings from GA

Excel’s MID Function.

Mid’s arguments are Text, start number, and number of characters. Rather than hard-coding values like 4 or 10 into the arguments for Mid, it’s better to calculate the start number and characters based off of ‘Landmarks’ within your string. (When working with complex excel formulas for the first time, I like to break them down into individual formulas, then re-nest them all at the end using a good text editor.) Say we want to take a referral string from google that looks like this

http://www.google.com/search?q=jared+huber&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

and extract the actual search query (it’s the stuff starting at “q=” and ending at the “&” after that). To use Mid, we’d first have to define a start number. In this case we can use the FIND function to help us locate the “q=” within the URL string. (FIND returns a number that corresponds with the first occurrence of one string within another text string). We’ll use:

=FIND("q=",A3)

which has a value of 30, along with

=FIND("&",A3,B3)

where B3 is the output of the previous find function.

Excel Mid Find Functions

Excel Mid Find Functions

Putting these together, we want to use mid with a start of 30, and a length of 43-30 or 13 characters.

Our formula now looks like this:

=MID(A2,B2,C2-B2)
Mid Function 2

Mid Function 2

Excel Formula Consolidation using Find & Replace

Now’s the time for that handy text editor. Let’s clean up the formula by substituting all of the values with their original formula. This basically allows us to put it all in one cell, rather than sprawling it in several cells in the spreadsheet. If this seems vaguely reminiscent of something you had to do in Algebra class, it’s because it is. Grab the formula in D2 “=MID(A2,B2,C2-B2)”, and put it into notepad (or textwrangler, if you’re lucky enough to use OS X on a daily basis). Do a find-replace (ctrl+H), and replace all instances of ‘B2′ with the formula we had in cell B2, ‘FIND(“q=”,A2)’. Likewise, find-replace all instances of ‘C2′ with our formula in C2, or FIND(“&”,A2,B2). You’ll probably have to do one more, replacing B2 again with our B2 formula. What we;re left with looks incredibly complicated (and may make you look like an excel guru), but in reality, it’s several systematic steps to produce an error-free result.

=MID(A2,FIND("q=",A2),FIND("&",A2,FIND("q=",A2))-FIND("q=",A2))

Cleaning up the output

You can then adjust your mid to exclude the q= by hardcoding a +2 on the start point and a -2 on the endpoint, or using the right function on the output and lopping off the first 2 characters. Additionally, you may want to substitute the + characters in the output with spaces to reflect the true search query.

=RIGHT(SUBSTITUTE((MID(A2,FIND("q=",A2),FIND("&",A2,FIND("q=",A2))-FIND("q=",A2))),"+"," "),LEN((MID(A2,FIND("q=",A2),FIND("&",A2,FIND("q=",A2))-FIND("q=",A2))))-2)

{ 2 comments }

Facebook Advertising – Free Market Research

by Jared Huber on May 10, 2010

I love the “Responder Profiles” and “Responder Demographics” reports in Facebook. Not only do these allow you to easily expand your pay per click ad targeting (within Facebook or elsewhere), they also gives you terrific insight into the likes and interests of those that are likely to respond to your ad, which can drive advertising and business development decisions in other marketing channels, including offline.

Since Facebook users willingly share their likes and interests with Facebook and each other, they’re also sharing them with advertisers. (Their loss; our gain. So much for privacy, I guess) You can target your Facebook pay-per-click ads to Facebook users based on their stated interests. This is pretty straightforward, and automatically beats the crap out of Google AdWords’ content network in terms of relevant ad targeting.

The real power of the platform comes after you’ve launched an ad and had the opportunity to amass a few hundred clicks. The reporting tool will then tell you the other likes of those that clicked on your ads, as well as the likes that are ‘overindexed’ in terms of clickthrough rate.

Categories of ‘Likes and Interests’ that you’ll have this visibility into include Interests (free form test entry field) and media such as Books, Movies, TV shows, and Music. I learned recently that our audience was also likely to enjoy Disturbed (the band), Harry Potter (the book series) and Firefly (the TV show).

Another great report is the ‘Responder Demographics’, which gives you all the demographic data you could want about people who clicked on your ads. State, age and gender data for your ‘likely prospects’ may not have been available without a pricey market research.

In a sense, you’re buying clicks on Facebook, but getting a full market research report for free. Use this information to create new ads on Facebook, but also to identify other ad opportunities. For example, buy TV ads on a TV show that you discovered through these report, offer giveaways of Books or video games that your audience has expressed an interest in, target folks in other channels based on their demographics, etc.

How are you using this data?

{ 1 comment }

Why Averages Suck

May 7, 2010

This data is from Google’s new AdWords Conversion Funnels “Time Lag” report. The graph and the heading say it all. Although 90% of my vistors complete a task within an hour, the “average” task completion time is 7 hours. Because of the skew (some people take several days), calculating the average of a long tail [...]

Read the full article →

4Q adds Google Analytics Integration

May 7, 2010

4Q is the free onsite survey tool offered by iPerceptions, based on the premise of asking visitors 4 simple questions about the purpose of their visit and overall satisfaction with the experience. VOC (voice of the customer) solutions are hot, and understandably so; web analytics does a lousy job of explaining why a visitor came [...]

Read the full article →

Regular Expressions in Google Analytics

May 6, 2010

Google Analytics grew up out of Urchin, a log-processing tool designed for tech-savvy webmasters who were used to using shell scripts and perl to automate common tasks in Unix. When Google bought Urchin, they turned in into a software as a service, dramatically improved the usability and functionality. However, a lot of the features within [...]

Read the full article →

How not to move your WordPress blog from one host to another

May 4, 2010

Posting has been somewhat quiet recently because I started getting a bit more serious about the site’s infrastructure in an error to give the site’s visitor’s a better experience while hopefully improving the site’s SEO. Namely, I dumped godaddy as my hosting provider and updated my wordpress theme to thesis. The process has been surprisingly [...]

Read the full article →

Does your focus on acquisition marketing damage your retention?

April 29, 2010

Acquiring new customers can cost up to 7 times as much as retaining an existing customer. It seems that the focus of most companies should be to retain as many exsting customers as humanly possible, then, (secondarily) growing the top line by attracting new business by filling the funnel. From an overall ‘cost per customer’ [...]

Read the full article →

Obsolescence of Obfuscation

April 25, 2010

One business model involves taking information that is largely available elsewhere for free, putting it behind a pay- or registration wall, and charging for admission. Let’s call it the obfuscation business model. It’s not a novel concept, nor is it entirely a sham. In theory, the verticalization or aggregation will add a certain amount of [...]

Read the full article →

Tracking Full Referral URLs in Google Analytics

April 22, 2010

The Referring Sites report gives you a good, general idea of where your referral traffic is coming from. If youre like me, however, the data in this report feels you wanting a bit more detail that may or may not be available on the “Referral Path” drilldown report. This report strips out query strings in [...]

Read the full article →

Matched Search Query in Google Analytics

April 21, 2010

When buying keywords in AdWords, it’s possible to use several different match types which control how your ads are shown. Exact match, whose symbol is [keyword], will show an ad only if the search query (what the user types into the search box) matches exactly your ‘bid keyword.’ That’s relatively straightforward. Phrase match, symbol is [...]

Read the full article →