Archive for the ‘analytics’ Category

Is (not provided) Driving You Crazy? Get Some of Your Data Back

Tuesday, October 25th, 2011

Google’s big announcement left many organizations angry about the loss of data. Since traffic now comes into Google Analytics as (not provided), we lost our ability to conclusively separate branded traffic from non-branded. Not only would we run the risk of over reporting the results of SEO efforts by allowing (not provided) to remain in our reports, but all of the other metrics, especially conversion rate, would also be affected.

Although we can no longer see the exact keywords searched, we can still pair the (not provided) information with the landing page for each visit. We want to pair this information because the landing page topic will give us a good indication as to the keyword used, if the keyword wasn’t branded.

There are three options below for how to get this data, with the first option being the easiest and the third requiring administrator access to your Google Analytics account.

Note: If you already have a good way to get this data, skip down to the “Next Steps” portion below.

Option 1 – Create Filter to View Keyword + Landing Page

Setup:

Step 1 - Add Secondary Dimension Landing Page

Step 2 - Filter to Include Keyword Containing not provided

Option 2 – Create Advanced Segment to Include Only not provided

Setup:

Once this segment is created, it can be used across multiple profiles, and can be used on almost all reports in Google Analytics. So to get to the landing page information, just get to the Landing Pages report.

Option 3 – Create a Brand New Profile to Include not provided

Create a profile that replicates all of your existing settings and goals.

Tip: See #3 in this post for information to automatically copy your profile settings into a new profile.

Create this filter to only include (not provided) traffic:

Next Step

Regardless of which of the three options you selected, you can use the results for the next step.

You need three key numbers from your analytics tool:

If you have these three numbers, you know what percentage of the site’s Organic Traffic is branded. If we apply the same percentages to our (not provided) numbers, we are left with a reasonable estimate of how those numbers break down. This can be done on the site level, or on an individual landing page level.

Also keep in mind that sites receive branded traffic to different pages. For example, in looking at ten sites, we found the majority of the branded traffic lands on either the homepage or a Login page. This is why you want to break out Landing Pages separate from the Overall numbers. With our downloadable spreadsheet, you can break out the traffic to a site’s top Landing Pages to determine if any branded bias exists for your site, as well.

Want to run the same analysis yourself? Get the spreadsheet here.

Tip – You can use this RegEx for most sites to find the branded breakdown for homepage and login pages in GA: ^\/$|^\/index|^\/default|^\/home|login

Finally, create an alert an Alert to notify you when traffic from (not provided) increases by x%, with the percent varying based on the amount of this traffic coming into the site you’re evaluating. For example:

What is SEER Doing?

We’re in the process of editing all of our Search profiles to Exclude (not provided) traffic. We recognize this means we’re under reporting our efforts, as some of the traffic we’re excluding is non-branded, and that numbers will continue to decrease as Google rolls out the changes to more users. However, in the interest of keeping our reporting as honest and valuable as possible, we would rather under report than over.

What are you doing to combat the changes? 

10 Google Analytics Browser Extensions to Save Time

Friday, September 2nd, 2011

There’s only so much time in a day, which is why we always look for ways to automate repetitive processes.  When we could focus on developing tools to scale link research, writing macros in Excel to evaluate data, or hacking APIs, why waste time on basic, redundant tasks?  Browser extensions are a staple for time-saving, so check out these 10 extensions to save time while improving your use of Google Analytics.

1) Analytics Helper

Good for:  All Google Analytics Users
GA version: All
Browser: Chrome
Download: here
Disclaimer: Tool has occasionally given false negatives, particularly about issues with the code, but never gives a false positive. 

What it does: Notifies users immediately to whether the Google Analytics code is detected on a page while browsing. Includes the code type (asynchronous, traditional), any UAs present on the page, and a quick blurb on the code position.

2) Better Google Analytics

Good for:  All Google Analytics Users
GA version:  Old version
Browser: Firefox
Download: here
Disclaimer: Original userscripts don’t all function. 

What it does: A compilation of Greasemonkey userscripts by Erik Vold, Tyson Kirksey, and other talented developers, including some favorite functions:

3) Copy Profiles in Google Analytics

Good for: Google Analytics Power Users
GA version:  Old version
Browser: Firefox
Download: here
Disclaimer: Filter order is not maintained when profiles are copied. Doesn’t copy Event goals that were set up in GA v5. When working on a profile with Event goals already set up, Paste functions times out when it gets to that goal.

What it does: This is a Greasemonkey script that makes it easy to replicate Google Analytics profiles. When goals, filters, users, and settings are 90% the same across 10 profiles, why waste time creating the same initial profile 10 times? This script literally lets users hit “Copy” and “Paste” to have the initial work automated.  Plus it’s really fun to watch while pasting!

4) Goal Analytics Goal Copy

Good for: Google Analytics Power Users
GA version:  Old version
Browser: Firefox
Download: here
Disclaimer: Works on up to 5 goals. Doesn’t always save the “Required step” checkbox. Doesn’t copy Event goals that were set up in GA v5. 

What it does: When profiles are already in place, #2 above is not a good solution, but neither is manually creating the same goal a dozen times.  Solution? GoalCopy Firefox extension! Copy individual goals from one profile to another.

5) GA Bookmarks

Good for:  Google Analytics Power Users
GA version:  Old version
Browser: Chrome and Firefox
Download: here

What it does:This tool also copies goals and filters, as well as profiles, by creating easy bookmarks. (Prior to the creation of #6 below, I always used this for Chrome. Now I use this tool primarily to set the filter order across multiple profiles.)

6) GA Copy & Paste (aka My New Favorite Plugin)

Good for:  Google Analytics Power Users
GA version:  New version
Browser: Chrome
Download: here
Disclaimer: Not sure what the limits are yet. At one point, I had 11 goals and six filters saved. This tool is still being worked on.

What it does: Similar to #4 above, GA Copy & Paste is a brand new Chrome plugin. Props to Educardo Cereto of Cardinal Path for this tool! Goals and filters are ridiculously easy to copy and paste, even easier to delete. The appearance is clean and perfectly matches GA.

7) gaSwitchr

Good for:  All Google Analytics Users
GA version:  Old version
Browser: Chrome
Download: here

What it does: Switch between profiles, but keep the report and date settings.

8) Straight to Google Analytics

Good for: All Google Analytics Users
GA version:  All
Browser: Chrome
Download: here

What it does: Jump right into Google Analytics without clicking the “Access Analytics” button.

9) RegEx Checker

Good for:  Google Analytics Power Users
GA version:  All
Browser: Chrome
Download: here

What it does: Handy little browser add-on Regular Expression checker to use when creating filters and goals.

10) Google Analytics Debugger

Good for:  Google Analytics Power Users
GA version:  All
Browser: Chrome
Download: here

What it does: Check your analytics code for errors without waiting 24 hours.  Detailed explanation from Chris Le can be found here.  (Firecookie can be used similarly for Firefox, but I never use it.)

Bonus – Add-on Compatibility Reporter

Good for:  Everyone
GA version:  N/A
Browser: Firefox
Download: here

What it does: This last tool isn’t GA-specific, but is probably one of the biggest lifesavers on the list.  Looking at the Firefox extensions, they aren’t all compatible with the latest version of Firefox. However, I’m not willing to lose my favorite extensions when Firefox updates. The Add-On Compatibility Reporter extension prevents Firefox from checking compatibility. Almost every extension keeps working, no matter which version of Firefox is being used.

Were any of your favorite tools missed? Share them in the comments below!

3 Algorithm Changes & 3 GA Changes in 30 Days

Wednesday, August 24th, 2011

From Panda to 12-Pack Site Links and GA changes in session tracking and image search, can you trust any GA numbers?

Google Change History July-August 2011

Well, yes. Just because you read about a change, doesn’t mean you’re affected. It is always best to check your own numbers when you consider any of these type of changes. And as Brett covered in his post last week, GA can give you deceptive results. The nice thing is, you can often find these anomalies within the GA data itself with a little digging.

Your Actual Image Impact May be Minimal

At SEER, we started to see some increases in July around the time of Panda 2.3 & the image referral change. We didn’t want to dismiss these increases as image referrals without checking our own numbers first. After reviewing about a dozen clients who experienced visit increases, I noticed that the image referral impact for most of our clients was very minor! Despite the dramatic look of the referral drop graphs, many clients had a very small amount of traffic in this area. Consider this:

Referrals from imgres moved to Search in Google Analytics

Yes, an 80% drop is good confirmation of that dramatic drop graph, but wait a minute, that’s only 47 visits that potentially shifted to Search. This particular site had about 48,500 search visits those weeks. That is a 0.10% impact. Most of our clients had impacts like this or even less.

Looking at Trends to Measure Real Impact

Of course, we did have some clients with a larger impact within the images that we didn’t want to dismiss. To look at these, I stacked the Organic Google Search Visit numbers with the Image Visit Numbers in Excel. Notice that the net effect is still up.

Although Image Referral Visits moved to Search, the net effect is still up.

Using Unique Visitors to Assess Panda & 12-Pack Impact

For the session tracking issue, SEOMoz already covered looking at Pageviews and Unique Visitors to see through the GA session tracking issue.

Applying a similar concept, to look at the impact of the 12-pack I created a very simple custom report that looks at Unique Visitors first by Source, then drills to Keyword. (If you don’t want to make it yourself you can use mine.)

With just one week of data, we see the site brand is getting a slight boost, and brands they carry are taking a slight hit. Our overall Google impact is about 1% so far, but to really draw any conclusions we’ll need a few more weeks living with the 12-pack.

Using Unique Visitors we can asses the impact of the 12-Pack branded links on visits outside of the session change issue.

Check Your Numbers

As I said at the beginning, this post started because we were checking our own numbers against the issues brought up by other bloggers. Every client we looked at had a different impact for each of these 6 changes in the last 30 days. Once you’ve checked your numbers, leave a comment below and let us know what you’re seeing.

Beware: Google Analytics May Be Lying to You

Wednesday, August 17th, 2011

Many people have noticed and commented about the recent changes to how Google Analytics handles how sessions are reported or how image referrals are tracked.  As part of reviewing the effects these changes may have had on our clients, I wanted to dig into our Analytics to make sure that our data is as accurate as possible.  One of the great things about working at an agency is you have tons of data sources in all sorts of industries and verticals, so identifying systemic issues becomes much easier.

However, when digging into this data I found some startling things results that date back well before the above-mentioned changes went into effect.  To be clear, the below examples are not (in my humble opinion) a result of or even correlated to the recent changes to Google Analytics, but are certainly something you should review when validating your past and future numbers.

Referring Keywords

Now, the first place I turn when validating data is always Google Analytics, the source of data (imagine that!).  When I was taking a look at some data for a client that saw increases as of late, at first things looked great; our targeted keywords were moving in the right direction and there were no abnormal spikes across one or two keywords that would indicate spam or faulty reporting.

But just as I was cinching up my party hat and lacing on my dancing shoes, I noticed some strange long-tail terms driving traffic.  Take this example:

Not only is this an 8-word phrase that is only vaguely related to the client in question, the grammar is all out of whack.  In fact, Google even tried to correct me when I search for this:

So now that this has caught my attention, I wanted to dig a little deeper.

Please Note: I recognize that 25 visits is not something that will necessarily make-or-break our reporting.  However, this is just an example of how this phenomenon was observed over a bunch of keywords across multiple clients. 

Now, we know that we recorded 25 visits over the past month, but how were these split up?

Hmm, ok.  Already I’m scratching my head but at the same time, our judicial system requires us to prove beyond a shadow of a doubt, so maybe a news story or a algorithm shift got us some temporary rankings for this phrase.  Skeptical as I was, if these visits were legitimate, you would think there would be some variation in the source, right?  Well, according to the same Google Analytics that tells us we got a spike in visits for this keyword, all of these visits came from the same City:

Note: When changing our location to Castro Valley, the website did not appear until the #11 result on Google Chrome Incognito (to prevent personalization bias).

The visits also all came from the same browser:

And even the same Screen Resolution:

So now that I’m pretty confident there are some issues here, I wanted to give 2 more examples of where we’re seeing this issue arise under different circumstances.

Do I Have a Stalker?

In a client call earlier this week, we discussed the curious fact that one of the top traffic-driving keywords for the entire month of June was the name of one of the Sales Executives.  Now, if this were the CEO or Directory of Marketing that just spoke at a conference or was featured on the news, that would be one thing.  No, this was a Sales Executive who herself was a little confused as to why her name would drive so many visits to the corporate website.  When looking into the data, we saw a lot of the same consistencies we referenced above: same browser, operating system, city, screen resolution, etc.  However, what was different about this example was that the visits were actually dispersed over several days:

Let’s Put it to the Test!

To figure this out, the client performed a test; they copied a random block of text from their homepage and clicked through to their listing in Google.  What happened next gives us the greatest cause for concern: over the course of the next week, the client did not close the tab by which he had accessed the SERP listing.  To be clear, he did not revisit this tab, refresh the tab, or re-search for the query in Google.  However, over the course of a week the 1 visit that he made as a test was actually being recorded as 27 visits in Google Analytics:

You will notice that there were no visits recorded on Saturday and Sunday, when he was out of the office and not actively using his computer.  While we’re not certain what caused this activity, there are some speculation that it may have been an auto-refresh in the browser or that the visits were recorded as the computer recovered from “Sleep Mode,” but we have no confirmation to this point (We are, however, currently testing if this might be the case)

Once the tab was closed and the cache was cleared on Friday, July 22, these visits were no longer being recorded and the traffic for the keyword returned to zero.

They Just Can’t Get Enough!

The last example we have shows how we can look to recognize potential faulty reporting by looking for abnormalities in your metrics.  The term in question is one that we’ve been tracking for quite some time, so we know for a fact that rankings on this term have not moved over the course of the past 2 weeks.  However, this week we saw visits spike with no discernible explanation.  The Sherlock Holmes in me was, once again, intrigued.  How did a term that experienced no rankings movement, no notable new references, and no changes in search activity that I could distinguish spike so much?

Rather than rehash the above points, I suggest you also take a look at any abnormalities in pages per visit or average time on site, as these will show you places where there was unusual (and potentially incorrect) reporting of the activity taken on your site.  Normally, we wouldn’t place too much stock in these metrics but for the sake of this argument they do provide a valuable insight into shortcomings of Google Analytics.  You will notice from the below that we saw absurd increases in these metrics:

The biggest thing to look at here is the comparisons to the site average:  if we averaged 55 pages per visit, this wouldn’t be remarkable.  However, a 1300% increase in pages per visit and almost 1600% increase in average time on site is even more of an indicator that there is something wrong with how this data is likely skewing your results to appear more favorable.

So what does this mean for you?

Before you celebrate monumental wins (or losses for that matter), you should always validate the data.  Just as we should always consider “what strategy may have caused this?” we should also consider what reporting deficiencies may have caused it.

Another suggestion is to look at Unique or Absolute Visitors, which from our review seem to provide more realistic numbers and are not affected by (for example) the changes to how sessions are being recorded.

Finally, always make sure you’re looking beyond your top 3, 5, or even 10 keywords.  While a reporting error of 25 visits (as with our first example) may not be a huge deal, a 25-visit error across 50 or 100 keywords can, in the aggregate, seriously hurt the validity of your data.

Are you seeing similar results in your data?  We encourage you to share your thoughts or feedback in the comments section below.  If you have specific questions you can also feel free to reach out to Brett on Twitter.

[VIDEO] Checking the Google Analytics Code Without Waiting

Wednesday, June 22nd, 2011

In this video, I’ll show you how to check your Google Analytics tracking codes without needing to wait for the data to show up in Google Analytics.

Links:

Google Analytics Debugging Tool

ScreenFlow

Transcription:

Hey everybody, this is Chris and I’m a developer here at Seer Interactive.  Today, I’m going to show you how to use the Google Analytics debugging tool to make sure your GA changes and code changes work without needing to wait 24 hours for the data to show up.  We’ll be using the Google Analytics Debugging Tool.  So let’s just get started!

On the left hand side of the screen here, I have the webpage in question and on the right hand side near the top, I have the HTML code for the webpage and at the bottom, I have my Apache log.  So, when I go to the page and refresh it, I can see some stuff happening.  We’ll see the HTML run, grab a picture, and try to grab the favorite icon.  But we don’t have one, so it’s not there.  No big deal.

Let’s take a quick look at the HTML first down here, somewhere on line 121.  This is our Google Analytics code.  It’s the top half of it that sets up the account and starts to track our page views.  The second half is actually at the bottom.  You’re allowed to split it.  That’s OK.

This is our form.  Somebody fills in the form, hits the submit button, and it sends them off to a PDF file. What we want to do is track when somebody hits that submit button and gets a PDF.  That’s what we want to track.

So, to do that, you’ll need to get the Google Analytics debugging tool.  To get that, just type in “google analytics debugger chrome” into Google.  (Or just follow this link) And I think it’s the first link. Yup.  There it is.  Go ahead and install that plugin and what we need to have it turned on so I’m just going to right click on it and turn it on.  (Correction: left click!)  My plugin is already turned on so I’m ready to go.

Now that I’m ready to go, I’m just going to hit refresh one more time. Alright.  Great.  And I’m going to right click on any part of the page and  click on inspect element.  The first thing it’s going to do is send me to the elements page.   We want to click over to the consoles page.

You can see that this consoles page shows us everything that’s happening with Google Analytics.  So here’s our tracking code, and there it is, our tracking code as reported by Google Analytics.  _trackPageView, and there it is again it’s tracking our page view.   The rest of this stuff is just information parsed out from this giant URL.  The hit ID, the referring URL,  page, time, session time, local time, what my browser is, you know.  Things of that sort.

What we’re going to be doing is filling in the form and what we want to see is our virtual page view show up at the bottom of this list as soon as we hit that submit button. So again, we’re looking for our tracking page view, this URL, and looking for it way down here at the bottom. So let’s go try it out!

Type into the form.  Test, test, test, and my email address which is very much not a real email address, but that’s OK, and hit submit.  It should show up here.  Now, this is going to show up pretty quick because this is going to refresh and immediately go to a PDF which means all this stuff on the screen is going to go away.  But I’m going to rewind the tape (video, actually) so we can actually see it and I’ll show you how it works.

So we hit submit now.  Boom!  There you go!  Did y ou see it?  You might have missed it. That’s OK.  You’ll notice that before we hit submit, it did actually go to the form, register through the 3rd party data collection stuff for the form, and gave us back the PDF.  So we know that the form itself worked and I’m pretty sure that our tracking worked too. But I’m going to rewind the tape (aka, the video) to check to make sure that works.

So this is ScreenFlow.  This is the program I used to record this video but what I’m really interested in seeing is slowing down the time and watch the processing that’s happening.

So I’m right here, right at the point where we are about to hit the submit button.  I’m going to scroll this over a little bit until maybe about… Hit submit now?  There it is!  I hit submit and we can see our tracked page view and our URL registered with Google.  It actually sent the tracking beacon.

You’ll notice it hasn’t actually refreshed the page just yet. If I scroll a little bit further… there it is.  It just refreshed the page, it grabbed the PDF, all of our information (on the screen) is gone and you’ll see the browser … just about here … there it goes… renders the PDF.

And that’s it!  So now we definitely know this works so we can probably push this out to the real website and I’m pretty sure it’s going to work now.

So that’s it.  Hopefully, it will help you guys out without having to wait 24 hours.  Talk to you later!

15 Things I Hate About the New Google Analytics

Tuesday, April 12th, 2011

We’ve been testing the new Google Analytics for some time now. I have a separate list of shiny new functions that I’m enjoying, but wanted to share the areas I’m running into difficulties with the new Google Analytics.

1) Report Export – Critical
The only options to export reports right now are CSV, TSV, and CSV for Excel. The CSV for Excel exports aren’t functioning properly, so users get CSVs instead. PDF is not an option at the moment.

Want to weigh in on PDFs being necessary? Now’s your chance.

2) Schedule & Email Reports – Critical
Not an option in the new version at this time. This is a HUGE ISSUE!

3) Date-Over-Date Comparison – Critical
Although you can view data from two date ranges, GA no longer shows the percent increase or decrease. Although the graph can be helpful for a quick view, the date comparison is close to pointless without the percent change.

4) Goal Sets No Longer Show Visit Numbers – Important
When users switch from Site Usage to one of the Goal Sets, the number of visits is no longer displayed. Without the number of visits, there isn’t any context into whether a 100% conversion rate on a term is huge or inconsequential. Which of your terms do you think are more likely to have a 100% conversion rate – the term that drives thousands of visits each month, or the one that’s only ever driven one visit?

Note: Google’s Aruna.J is escalating this to the engineers to be addressed. Thanks Google!

5) Graphing by Week – Annoying
Unlike the old version, you can’t select a week with a single click.
Old Version:

New Version:
OR you could pick your date range, THEN

Additionally, when you do graph by week, the date axis no longer works properly. The image below is from a graph that shows March 1, 2010 through March 31, 2011. The only information about the date is in the bottom-left, and says “Mar 1 – Apr 30.” Would you think that’s a weekly review that spans over a year and ends on March 31? Me neither.

6) Can’t Add Reports to Dashboard From the Report Page – Annoying
In the old GA, you can drill into any report with any search information you wanted, then add to the Dashboard with a single click:

In the new version, you need to go back to the Dashboard page, Add a Widget, and try to replicate the settings. “Try” is the operative word, since you can’t effectively filter or segment the information in the dashboard yet.

7) Graphs Don’t Update Based on Searches on Data – Annoying
When you enter a filter into the “Search” function, the data updates but the graph does not. For example:
Pre-Filter

Filter

Post-Filter

8 ) Export 50K Rows – Annoying
Google Analytics still only shows a maximum of 500 rows. Previously, users could use &limit= to export 50K rows. This is now capped at 20K. This would be a higher priority item if we didn’t use the GA API.

9) Settings & Navigation – Annoying
To see the settings for the profile you’re currently on, you need to click the top-right cog link, then find the account you’re working on, then find the site within that account, then finally find the profile within that account. Too many steps to get to something simple. The same can be said for the navigation. There are too many clicks needed to get to reports that were previously easy to access. Props to Google for putting together the Report Finder to help people figure out where reports actually are; this thing has been hugely helpful.

10) Reports Not Migrating – Annoying
This one’s just annoying because you know it’s going to be fixed. Right now Custom Reports shows this message, which is an improvement over previous weeks:

If these reports aren’t going to be available in the regular version of GA, I’d like to see and select which reports I want to move over. I’ve hit this button previously – Nothing happened.

11) Graph Intervals Reset – Annoying
Viewing any report with the graph interval set to weekly or monthly works fine. If you try to switch to another report, the graph resets to daily. This isn’t conducive to navigating GA.

12) View Overall Conversion Rate – Annoying
With the old version, it was possible to see the overall conversion rate for any information (keyword, referring source, etc.). For example, with the new version, you can only see the conversion rate for a keyword for each individual type of conversion. Being able to see the overall conversion rate, combining all types of conversions, is helpful for analysis.

13) Can’t Switch Administrator to User – Minor Issue

14) Resizing Data – Minor Issue
The new version doesn’t resize the data to match the size of the browser window. Google fixed this issue for graphs last week, but the rest of GA hasn’t been fixed yet. For those of us who frequently screencap from GA, this can be annoying.

15) In Page Analytics – Minor Issue
This tool isn’t in the new GA yet. Honestly, this doesn’t matter. Until this tool shows the percent of clicks on individual links, instead of URLs, the tool has little value. This made the list (barely) because I’ve had to answer so many questions about how to get to In Page Analytics in the new version.

Bonus) One more, just for fun:

All of this said, there are some amazing new features. It’s obvious that Google is working hard to improve the tool while it’s in beta. Comparing this week to several weeks ago, the new GA is much faster. Looking forward to seeing what comes next!

Follow Rachael on Twitter @rachaelgerson

Google Analytics Data Export API with Ruby + Gattica

Tuesday, February 22nd, 2011

Download Gattica (with goals and segment support) on GitHub

Getting Google Analytics data export API is amazingly fun!  I originally contributed to the open source Google Analytics library for PHP.  Recently, I’ve been coding in Ruby for it’s speed and agility.

Ruby is amazing!  In 15 lines of code I could get all visits, bounces, for every client, by month.

To date, Ruby only has two Ruby Gems to interface with the Google Analytics API: Garb and Gattica.  Unfortunately, they both seem to be missing some of the deeper areas of the API:

Why Garb’s and Gattica’s code didn’t work for me

Solved: Wrote code. Made available to everyone

So, my solution was to add my proverbial brick to Gattica so that it supported goals and segments.  You can download my fork of Gattica on GitHub.

Quick start for developers:

Include it your Rails app by adding one line to your gemfile

gem 'gattica', '>=0.3.3.4',
:git => 'git://github.com/chrisle/gattica.git'

(Make sure to run ‘bundle install’ afterwards.)

Or… download and build it yourself

wget https://github.com/chrisle/gattica/tarball/master
tar -zxvf chrisle-gattica-*
cd chrisle-gattica-*
git build gattica.gemspec
git install gattica

Conntect to Google Analytics

ga = Gattica.new({  :email => 'johndoe@google.com',
                   :password => 'password',
                   :timeout => 500 })

Collect the accounts that the authenticated user has access to and show them on the screen

accounts = ga.accounts
accounts.each do |a|
   puts a.title  # => "www.mywebsite.com"
   puts a.web_property_id  # => "UA-1234567-12"
   puts a.profile_id  # => 55555
end

Specify an account and get visitor and bounce data for this month

ga.profile_id = 55555
results = ga.get({ :start_date => '2011-01-01',
                   :end_date => '2011-02-01',
                   :dimensions => ['month', 'year'],
                   :metrics => ['visits', 'bounces'],
                   :sort => ['year', 'month']})

Find the first profile that has goals

first_profile_with_goals = accounts.detect {
   |a| a.ga_goals.count > 0
}

Collect a list of segments available to the authenticated user and display them

all_segments = ga.segments
all_segments.each {|s| puts "name: " + s.name + ",  id: " + s.id}

Segment by a mobile traffic (Google’s default user segment gaid::-11)

ga.profile_id = 55555
mobile_traffic_segment = "gaid::-11"
results = ga.get({ :start_date => '2011-01-01',
                     :end_date => '2011-02-01',
                     :dimensions => ['month', 'year'],
                     :metrics => ['visits', 'bounces'],
                     :sort => ['year', 'month'],
                     :segment => [mobile_traffic_segment]})

Thanks to code ninja Bob Brodie of Sumo Heavy fame for introducing me to Ruby On Rails.

Subscribe

Subscribe to our RSS Feed

Support

Get our Newsletter

Keep up-to-date search trends, latest blog posts and more.