All Projects → tpitale → Legato

tpitale / Legato

Licence: mit
Google Analytics Reporting API Client for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Legato

Next Ga
Next.js HOC to integrate Google Analytics on every page change
Stars: ✭ 228 (-43.98%)
Mutual labels:  analytics, google-analytics
Social-Media-Monitor
Automatically monitor and log fan counters from social media(Facebook Pages, Twitter, Instagram, YouTube, Google+, OneSignal, Alexa) using APIs to Google Spreadsheet. Very useful for website admins and social media managers.
Stars: ✭ 36 (-91.15%)
Mutual labels:  analytics, google-analytics
Centcount Analytics
An open-source web analytics software. Developed by using PHP + MySQL + Redis, Can be easily deployed on your own server, 100% data ownership.
Stars: ✭ 249 (-38.82%)
Mutual labels:  analytics, google-analytics
Magento2 Google Tag Manager
Google Tag Manager is a user-friendly, yet powerful and cost-effective solution that is a must-have integration for every Magento store. It simplifies the process of adding and managing third-party JavaScript tags. With dozens of custom events and hundreds of data points our extensions the #1 GTM solution for Magento.
Stars: ✭ 208 (-48.89%)
Mutual labels:  analytics, google-analytics
wp-analytify
Google Analytics Dashboard Plugin For WordPress By Analytify
Stars: ✭ 20 (-95.09%)
Mutual labels:  analytics, google-analytics
Analytics
UNMAINTAINED! - Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor
Stars: ✭ 211 (-48.16%)
Mutual labels:  analytics, google-analytics
web-analytics-handbook
Handbook - Rendezvous between developers and web data
Stars: ✭ 23 (-94.35%)
Mutual labels:  analytics, google-analytics
Save Analytics From Content Blockers
A proxy back end for Google Tag Manager & Google Analytics
Stars: ✭ 159 (-60.93%)
Mutual labels:  analytics, google-analytics
aws-web-analytics
Privacy-focused alternative to Google Analytics on AWS Pinpoint
Stars: ✭ 45 (-88.94%)
Mutual labels:  analytics, google-analytics
svelte-google-analytics
Google Analytics component for Svelte
Stars: ✭ 41 (-89.93%)
Mutual labels:  analytics, google-analytics
React Tracker
React specific tracking library, Track user interaction with minimal API!
Stars: ✭ 191 (-53.07%)
Mutual labels:  analytics, google-analytics
Signal
Simple and beautiful open source Analytics 📊
Stars: ✭ 295 (-27.52%)
Mutual labels:  analytics, google-analytics
Goaccess
GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
Stars: ✭ 14,096 (+3363.39%)
Mutual labels:  analytics, google-analytics
Ackee
Self-hosted, Node.js based analytics tool for those who care about privacy.
Stars: ✭ 3,140 (+671.5%)
Mutual labels:  analytics, google-analytics
Angulartics
Analytics for AngularJS applications.
Stars: ✭ 1,966 (+383.05%)
Mutual labels:  analytics, google-analytics
dashflare
🕵🏼‍♀️ Open Source and privacy-focused analytics solution. 📊 Advanced monitoring for your website behind Cloudflare
Stars: ✭ 78 (-80.84%)
Mutual labels:  analytics, google-analytics
Vue Analytics
Google Analytics plugin for Vue
Stars: ✭ 1,780 (+337.35%)
Mutual labels:  analytics, google-analytics
Komito
🔖 Komito Analytics is a free, open-source enhancement for the most popular web analytics software.
Stars: ✭ 148 (-63.64%)
Mutual labels:  analytics, google-analytics
Stop.Google.Analytics.Ghost.Spam.HOWTO
How to stop Google Analytics "Ghost" Spam using a well curated list of spam referrer domains and web sites. Simple and easy to use with instructions for creating Segments in Google Analytics using our google-exclude files.
Stars: ✭ 21 (-94.84%)
Mutual labels:  analytics, google-analytics
Laravel Gamp
📊 Laravel Google Analytics Measurement Protocol Package
Stars: ✭ 271 (-33.42%)
Mutual labels:  analytics, google-analytics

Legato: Ruby Client for the Google Analytics Core Reporting and Management API

Gem Version Build Status Code Climate

Check out the Wiki!

Feel free to open an issue if you have a question that is not answered in the Wiki

Chat!

We're trying out chat using Gitter Chat. I'll try to be in there whenever I'm at my computer.

Gitter chat

If you've come here from Garb, welcome! There are a few changes from Garb, so you'll want to check out:

If you're not able to upgrade quite yet, Garb has been maintained https://github.com/Sija/garb

Google Analytics Management

  1. Get an OAuth2 Access Token from Google, Read about OAuth2

    access_token = OAuth2 Access Token # from Google
    
  2. Create a New User with the Access Token

    user = Legato::User.new(access_token)
    
  3. List the Accounts and Profiles of the first Account

    user.accounts
    user.accounts.first.profiles
    
  4. List all the Profiles the User has Access to

    user.profiles
    
  5. Get a Profile

    profile = user.profiles.first
    
  6. The Profile Carries the User

    profile.user == user #=> true
    
  7. The profile can also lookup its "parent" Web Property

    profile.web_property
    

Google Analytics Model

class Exit
  extend Legato::Model

  metrics :exits, :pageviews
  dimensions :page_path, :operating_system, :browser
end

profile.exit #=> returns a Legato::Query
profile.exit.each {} #=> any enumerable kicks off the request to GA

Metrics & Dimensions

http://code.google.com/apis/analytics/docs/gdata/dimsmets/dimsmets.html

metrics :exits, :pageviews
dimensions :page_path, :operating_system, :browser

Filtering

Create named filters to wrap query filters.

Here's what google has to say: http://code.google.com/apis/analytics/docs/gdata/v3/reference.html#filters

Examples

Inside of any Legato::Model class, the method filter is available (like metrics and dimensions).

Return entries with exits counts greater than or equal to 2000

filter(:high_exits) {gte(:exits, 2000)}

# or ...

filter :high_exits, &lambda {gte(:exits, 2000)}

Return entries with pageview metric less than or equal to 200

filter(:low_pageviews) {lte(:pageviews, 200)}

Filters with dimensions

filter(:for_browser) {|browser| matches(:browser, browser)}

Filters with OR

filter(:browsers) {|*browsers| browsers.map {|browser| matches(:browser, browser)}}

Using and Chaining Filters

Pass the profile as the first or last parameter into any filter.

Exit.for_browser("Safari", profile)

Chain two filters.

Exit.high_exits.low_pageviews(profile)

Profile gets a method for each class extended by Legato::Model

Exit.results(profile) == profile.exit

We can chain off of that method, too.

profile.exit.high_exits.low_pageviews.by_pageviews

Chaining order doesn't matter. Profile can be given to any filter.

Exit.high_exits(profile).low_pageviews == Exit.low_pageviews(profile).high_exits

Be sure to pass the appropriate number of arguments matching the lambda for your filter.

For a filter defined like this:

filter(:browsers) {|*browsers| browsers.map {|browser| matches(:browser, browser)}}

We can use it like this, passing any number of arguments:

Exit.browsers("Firefox", "Safari", profile)

Google Analytics Supported Filtering Methods

Google Analytics supports a significant number of filtering options.

Here is what we can do currently: (the operator is a method available in filters for the appropriate metric or dimension)

Operators on metrics (method => GA equivalent):

eql     => '==',
not_eql => '!=',
gt      => '>',
gte     => '>=',
lt      => '<',
lte     => '<='

Operators on dimensions:

matches          => '==',
does_not_match   => '!=',
contains         => '=~',
does_not_contain => '!~',
substring        => '[email protected]',
not_substring    => '[email protected]'

Session-level Segments

Your query can have a session-level segment, which works with filter expressions. It works like an advanced segment, except you don't have to create it beforehand, you can just specify it at query time.

Some of the numbers you'll get will be different from using a filter, since the subset of visits matched happens before dimensions and metrics are calculated (hover on the segment parameter to see).

Some metrics and dimensions are not allowed for segments, see the API documentation for more details.

Note: Legato does not support Users vs Sessions, yet. The default will be sessions (the equivalent of the earlier, now removed, dynamic segments).

Defining, using and chaining segments

Return entries with exits counts greater than or equal to 2000

segment :high_exits do
  gte(:exits, 2000)
end

Return entries with pageview metric less than or equal to 200

segment :low_pageviews do
  lte(:pageviews, 200)
end

You can chain them

Exit.high_exits.low_pageviews(profile)

and call them directly on the profile

profile.exit.high_exits.low_pageviews

Accounts, WebProperties, Profiles, and Goals

Legato::Management::Account.all(user)
Legato::Management::WebProperty.all(user)
Legato::Management::Profile.all(user)
Legato::Management::Goal.all(user)

Other Parameters Can be Passed to a call to #results

  • :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
  • :sort - metric/dimension to sort by
  • :quota_user - any arbitrary string that uniquely identifies a user (40 characters max)
  • :sampling_level - 'FASTER' or 'HIGHER_PRECISION' https://developers.google.com/analytics/devguides/reporting/core/v3/reference#samplingLevel
  • :segment_id - this will supersede any segments chained to the query

Real Time Reporting

https://developers.google.com/analytics/devguides/reporting/realtime/v3/ https://developers.google.com/analytics/devguides/reporting/realtime/dimsmets/

GA provides an endpoint to do basic reporting in near-realtime. Please read the above documentation to know which features (and dimentsion/metrics) are or are not available. It is also only available in beta so you must already have access.

Inside of Legato, you can simply add realtime to your query (#results returns a Query instance), like this:

Exit.results(profile).realtime

The results you iterate over (with .each, etc) will be from the realtime reporting API.

You can also call realtime on your model to get a new Query instance with realtime API set.

query = Exit.realtime
query.realtime? #=> true
query.tracking_scope #=> 'rt'

Managing Quotas

Assigning a quota_user or user_ip on a user instance will be used by management and query requests.

user = Legato::User.new(access_token)
user.quota_user = 'some_unique_user_identifier'
# OR
user.user_ip = ip_address_from_a_web_user_or_something
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].