0

Google アナリティクス API を使用してレポート ツールを開発しています。私はデータを引き出すことができるガーブを使用しています。私が直面している課題は、2 つの日付の間を取得するために start_date と end_date を指定する方法です。

   class Exits

  extend Garb::Model

  metrics :visits,:percentNewVisits
  dimensions :visitorType
end


  def registration
puts "entering the registration method"  
Garb::Session.login("email@email.com", "password")

profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == 'UA-xxxxxxxx-x'} 
report = Exits.results(profile, {:start_date =>2.day.ago, :end_date =>1.day.ago, :metrics =>[:visits]})
#report = Garb::Report.new(profile, {:start_date => 2.day.ago, :end_date => Time.now})
puts "entering the loop" 
 report = profile.exits()
  report.each do |re| 
  puts re
#puts "#{report.visits}"
#puts "#{profile.percent_new_visits}"
#puts "#{profile.visitorType}"
  end 

end 

終わり

2 つの日付の間のページ ビューやその他の指標を取得するのを手伝ってください。

4

2 に答える 2

2

これを試して:

    profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == web_profile}
    options =  {
                    :start_date     => (Date.today - 2),
                    :end_date       => (Date.today - 1),
                }

    result = Report.results(profile, options)
于 2012-10-08T15:48:29.617 に答える
0

README のドキュメントに関して:

Other Parameters
start_date: The date of the period you would like this report to start
end_date: The date to end, inclusive
limit: The maximum number of results to be returned
offset: The starting index

だからあなたはあなたが望むことをすることができます:

report = Garb::Report.results(profile, {:start_date => 2.day.ago, :end_date => 1.day.ago})
于 2012-03-07T08:47:04.950 に答える