Store data in database from GA API

Hi,

I use the gem gattica to acces our unique visitor data. This works fine
in my console.

require ‘rubygems’
require ‘gattica’

gs = Gattica.new({:email => ‘XXXX’, :password => ‘XXXXX’})
accounts = gs.accounts
gs.profile_id = XXXXXX

results = gs.get({ :start_date => ‘2010-02-17’, :end_date =>
‘2010-02-17’, :dimensions => ‘day’, :metrics => ‘visitors’})

output1:

{“start_date”=>Wed, 17 Feb 2010, “end_date”=>Wed, 17 Feb 2010,
“points”=>[{“title”=>“ga:day=17”, “dimensions”=>[{:day=>“17”}],
“id”=>“http://www.google.com/analytics/feeds/data?ids=ga:21180637&ga:day=17&start-date=2010-02-17&end-date=2010-02-17”,
“metrics”=>[{:visitors=>4088}], “updated”=>Tue, 16 Feb 2010 16:00:00
-0800}], “items_per_page”=>1, “total_results”=>1, “start_index”=>1}

output 2:
results.to_csv(:short)

“day,visitors\n17,4088\n”

I want to check the Google Analyticsc API with a frequency of 4 hours
and store the value of visitors (4088) in my database. How do i
realize this?

Grtz…remco

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs