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)

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.