PERL and Google Analytics Data Export API Segment Fix

As many of you probably know, Patrick Hartman created a very nice starter example for PERL and Google Analytics. However, for those of you that have had trouble passing the segment parameter into the URI, there is a fix. After some digging, I realized that Google was returning GData version 1, and not version 2. Since segments are a relatively new addition to the GA Data Export API, using version one, the request treats the segment parameter as “junk”. Therefore, if you are using Patrick Hartman’s code, in the gaDataFeed subroutine, change:

my @headers … (old)
to
my @headers = (“Content-type” => “application/x-www-form-urlencoded”, Authorization => “GoogleLogin Auth=$token”, “GData-Version” => “2″);

-Jeffrey Shih (shihzy@gmail.com)

Incorrect Datatype in Where Clause (MySQL)

I recently ran across an issue where I “mistakenly” used an integer in the Where clause of a MySql query against a field that had a data type of varchar (text or string). Because I did not have the schema for this particular table, I wrongly assumed the data type (which is why having a schema and proper naming conventions is important).  Below is an example of what happened:

Table – Test

Field Type
id int(11)
name varchar(100)

So, the query I ran was:

SELECT * FROM Test WHERE name = 123

The query still ran, but took forever.  I would imagine that the MySql engine automatically casted the 123 to a string type and did the comparison.  However, after realizing my mistake, the query took about 3 seconds versus a minute or so.

I thought this was interesting because I received no errors and was still allowed to run this query.  So, the morale of the story, never assume anything with MySql!

-Jeffrey Shih (shihzy@gmail.com)

Interview with AustinLifestyles, SXSW 2009

Found this old video interview of me at SXSW 2009 with AustinLifestyles during my time at Giganews.  Note: The cameraman was quite shaky that day.

-Jeffrey Shih (shihzy@gmail.com)

Explaining Twitter to People

Recently, a friend of mine stopped by my house for a late evening meeting.  To give some background, my friend recently quit his door-to-door sales job and was hired into the sales and marketing department with a local Austin event company (which, BTW, is a monstrous jump for anyone that has ever done low level sales).  As we were discussing marketing, Twitter (and also social media) inevitably came up in our discussions.  My friend asked, “What exactly is Twitter and how can I make my money from it?”

Obviously, the canned response would be “Twitter is a free social networking and micro-blogging service that enables its users to send and read messages known as tweets.”  (pulled directly from Wikipedia).  But realistically, its much more than that.  Here is a site that comes up on the first page of Google (http://tweeternet.com/) that has some good explanations.  Below is an interesting breakdown on how B2C companies are successfully using Twitter (courtesy of eMarketer)

Twitter Stats

-Jeffrey Shih (shihzy@gmail.com)

Two Weeks Until Winter Break?

Wow, time flies when you’re having fun.  I’m sure many of my fellow TEMBA 2012ers are feeling the same thing, where did this semester go?  After two mid-terms, a management project, a looming statistics project, and several debates on British Candies, I’m sure we are all excited about the much needed break (although we still have work).  I thought I would share what I have learned so far in the TEMBA program. (For those who are unfamiliar with TEMBA, it is the Texas Evening MBA Program at McCombs)

1.  What’s the best management decision?  It “depends”

2.  Bryan Dimery must have a frequent buyers card at the HEB Bakery

3.  There must be a giant warehouse somewhere at UT that has stockpiles of those hideous clear British mints (another hypothesis is that they self-replicate)

4.  It requires a team of 7 students to operate the projector in one of the AT&T Executive Classrooms

5.  You have a 500 MB download limit per week while on the UT system…. so no Usenetting in class :(

6.  I am still confused on Population 3 and/or Bobby’s Pile

7.  I am curious to see how many gold stars I have collected in Statistics, and how I can redeem these with Professor Sager

8.  TEMBA Professors, Faculty, and Staff are extremely accommodating and helpful

Overall, I had my doubts going into the program.  However, after the first semester I feel much more confident that it was the right choice.  The next 7 semesters should be quite interesting.

-Jeffrey Shih (shihzy@gmail.com)

Follow

Get every new post delivered to your Inbox.