我正在使用 Google Analytics API 开发报告工具。我正在使用Garb我能够提取数据。我面临的挑战是如何指定 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
结尾
请帮助获取两个日期之间的页面浏览量和任何其他指标。