EzDevInfo.com

legato

Google Analytics Reporting API Client for Ruby

Legato totalEvents different from web interface

I'm using the Legato gem to access the total number of a certain event from Google Analytics in Ruby, but I'm getting inconsistent results with the web interface.

I have a model like so:

module Analytics
    class ViewedContent
        extend Legato::Model

        metrics :users, :new_users, :total_events        

        filter :my_org do
            # Look u[ event_label=X AND event_action=Y
            [
                eql(:event_label, "My Organisation", Legato.and_join_character),
                eql(:event_action, 'Viewed_Content', Legato.and_join_character)
            ]
        end
    end
end    

...then I use this by doing:

query = Analytics::ViewedContent.my_org.results(profile, {
    :start_date => start_date,
    :end_date => end_date
})

...and looking at the totalEvents stat.

When I pass in dates in January, e.g. start_date = "2014-01-01".to_date and end_date = "2014-01-31".to_date then it works fine, and returns the identical number of totalEvents to the Google Analytics web interface.

However, when I use it in for last month, start_date = "2014-07-01".to_date and end_date = "2014-07-31".to_date then it's considerably less than in the web interface (Legato returns 555 vs 662 in the web interface).

It makes me wonder if it's something to do with British Summer Time (I'm currently in UTC+1) except that even extending the date range by a day either side doesn't bring it up to the same as what the web interface reports, which would appear to rule that out.

Any thoughts much appreciated!


Source: (StackOverflow)