<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -50,17 +50,19 @@ module Statwhore
         end
         
         def pageviews(options={})
-          response = report(options.merge({:report =&gt; 'Dashboard'}))
-          doc = Hpricot::XML(response)
-          pageviews = (doc/:ItemSummary).detect { |summary| summary.at('Message').inner_html == 'Pageviews' }
-          pageviews &amp;&amp; pageviews.at('SummaryValue') ? pageviews.at('SummaryValue').inner_html.gsub(/\D/, '').to_i : 0
+          get_item_summary_by_message(options.merge(:message =&gt; 'pageviews'))
+        end
+        
+        def pageviews_by_day(options={})
+          get_serie_by_label(options.merge({:label =&gt; 'pageviews'}))
         end
         
         def visits(options={})
-          response = report(options.merge({:report =&gt; 'Dashboard'}))
-          doc = Hpricot::XML(response)
-          pageviews = (doc/:ItemSummary).detect { |summary| summary.at('Message').inner_html == 'Visits' }
-          pageviews &amp;&amp; pageviews.at('SummaryValue') ? pageviews.at('SummaryValue').inner_html.gsub(/\D/, '').to_i : 0
+          get_item_summary_by_message(options.merge(:message =&gt; 'visits'))
+        end
+        
+        def visits_by_day(options={})
+          get_serie_by_label(options.merge({:label =&gt; 'visits'}))
         end
         
         # takes a Date, Time or String
@@ -71,6 +73,29 @@ module Statwhore
         def to_s
           &quot;#{name} (#{profile_id})&quot;
         end
+        
+        private
+          def get_item_summary_by_message(options={})
+            raise ArgumentError unless options.has_key?(:message)
+            message = options.delete(:message).to_s.capitalize
+            response = report(options.merge({:report =&gt; 'Dashboard'}))
+            doc = Hpricot::XML(response)
+            pageviews = (doc/:ItemSummary).detect { |summary| summary.at('Message').inner_html == message }
+            pageviews &amp;&amp; pageviews.at('SummaryValue') ? pageviews.at('SummaryValue').inner_html.gsub(/\D/, '').to_i : 0
+          end
+          
+          def get_serie_by_label(options={})
+            raise ArgumentError unless options.has_key?(:label)
+            label = options.delete(:label).to_s.capitalize
+            response = report(options.merge({:report =&gt; 'Dashboard'}))
+            doc = Hpricot::XML(response)
+            serie = (doc/:Serie).detect { |serie| serie.at('Label').inner_html == label }
+            if serie
+              (serie/:Point).inject([]) { |collection, point| collection &lt;&lt; [Date.parse(point.at('Label').inner_html), point.at('Value').inner_html.to_i] }
+            else
+              []
+            end
+          end
       end
     end
   end</diff>
      <filename>lib/statwhore/google/analytics/profile.rb</filename>
    </modified>
    <modified>
      <diff>@@ -35,6 +35,16 @@ describe &quot;Statwhore::Google::Analytics::Profile&quot; do
     profile.pageviews.should == 283
   end
   
+  it &quot;should be able to get pageviews by day&quot; do
+    profile = Statwhore::Google::Analytics::Profile.new(:account_id =&gt; 344381, :profile_id =&gt; 543890)
+    xml = open(File.dirname(__FILE__) + '/fixtures/dashboard_report_webgroup.xml').read
+    Statwhore::Google::Analytics::Profile.should_receive(:get).and_return(xml)
+    dates = profile.pageviews_by_day
+    dates.first.should == [Date.civil(2008, 2, 8), 72]
+    dates.last.should == [Date.civil(2008, 3, 9), 0]
+    dates.size.should == 31
+  end
+  
   it &quot;should be able to get visits&quot; do
     profile = Statwhore::Google::Analytics::Profile.new(:account_id =&gt; 344381, :profile_id =&gt; 543890)
     xml = open(File.dirname(__FILE__) + '/fixtures/dashboard_report_webgroup.xml').read
@@ -42,4 +52,14 @@ describe &quot;Statwhore::Google::Analytics::Profile&quot; do
     profile.visits.should == 228
   end
   
+  it &quot;should be able to get visits by day&quot; do
+    profile = Statwhore::Google::Analytics::Profile.new(:account_id =&gt; 344381, :profile_id =&gt; 543890)
+    xml = open(File.dirname(__FILE__) + '/fixtures/dashboard_report_webgroup.xml').read
+    Statwhore::Google::Analytics::Profile.should_receive(:get).and_return(xml)
+    dates = profile.visits_by_day
+    dates.first.should == [Date.civil(2008, 2, 8), 67]
+    dates.last.should == [Date.civil(2008, 3, 9), 0]
+    dates.size.should == 31
+  end
+  
 end
\ No newline at end of file</diff>
      <filename>spec/statwhore_google_analytics_profile_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4d65ff259088ae2e0cf74f8507fff3df2733c06c</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/statwhore/commit/f8a190db137c777e1ada6031dd9037e6d3745fff</url>
  <id>f8a190db137c777e1ada6031dd9037e6d3745fff</id>
  <committed-date>2008-05-13T14:22:42-07:00</committed-date>
  <authored-date>2008-05-13T14:22:42-07:00</authored-date>
  <message>added methods to get pageviews and visits by day; refactored common logic in #pageviews, #visits and new methods by day into separate private methods</message>
  <tree>3ddc7447dab8836688b8b4277cfab8e0e95303ca</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
