SlideShare a Scribd company logo
1 of 92
Download to read offline
Rugalytics




Photo: Archie McPhee Seattle http://flickr.com/photos/archiemcphee/1444560125/
got
website
also
Ruby API?
jnunemaker
Statwhore

Photo: CARLOS62 http://flickr.com/photos/82887550@N00/352151895/
logged in
Analytics account
grabbed
<XML> reports
<MiniTable id=quot;BrowserMiniTablequot;>
      <Row>
        <Cell>
          <Content>
             <Value>8,995</Value>
          </Content>
        </Cell>
        <Cell>
          <Content>
             <Value>70.79%</Value>
          </Content>
        </Cell>
        <PrimaryKey>IE</PrimaryKey>
      </Row>
      <Row>
hardcoded
accessors
def pageviews
end

def visits
end
cool
wanted
MORE
wanted
to
   emerge
    class
definitions
 from data
 at runtime
   Photo: brilarian http://flickr.com/photos/bybri/4443691/
forked
Statwhore
kept
login logic
Google::Base
grabbed
C,S,V reports
#-----------------------
# BrowserMiniTable
#-----------------------
Browser,Visits,% visits
IE,89950,0.70787754
Firefox,27980,0.22019359
Safari,5640,0.044384984
made methods
from data
Morph




                                        Photo: Salt Fired
        http://www.flickr.com/photos/saltfired/201998836/
module Rugalytics

 class Item

   include Morph
def initialize labels, values
labels.each_with_index do
   |label, index|
attribute = normalize(label)
value = values[index]

morph(attribute, value)
under
 the
 rug
   Photo: LizMarie http://flickr.com/photos/perspicacious/104917207/
def morph_method_missing symbol,*args

 attribute = symbol.to_s.chomp '='

 base.class_eval quot;def #{attribute};
   @#{attribute}; end;
 def #{attribute}=(value);
   @#{attribute} = value; endquot;


 send(symbol, *args)
> require 'ruby2ruby'
> klass = Rugalytics::Item

> y Ruby2Ruby.translate(klass)
class Rugalytics::Item < Object
  def bounce_rate
    @bounce_rate
  end
  def bounce_rate=(value)
    @bounce_rate = value
  end
  def dollar_index
    @dollar_index
  end
  def dollar_index=(value)
    @dollar_index = value
  end
  def initialize(labels, values, base_url)
    labels.each_with_index do |label,
index|
       ...
controller
def top_content days

 profile = Rugalytics.default_profile

 from_date = Date.today - days

 report = profile.top_content_report
       :from => from_date
items = report.items

 items = items.sort_by { |i|
     i.unique_pageviews.to_i}

 items = items.reverse

 items = items[0..9] if items.size >10

  items
end
view
%ul
  - @top_pages.each do |item|
    %li
      = link_to(item.page_title,
            item.url)
      %span.page_views
        =quot;(#{item.unique_pageviews})quot;
lots of
reports

 Photo: CloCkWeRX http://flickr.com/photos/clockwerx/9267076/
def get_report_csv(options={})
  options = set_default_options(options)
  params =
convert_options_to_uri_params(options)

  self.class.get(
    quot;https://google.com/analytics/
    reporting/exportquot;,
    :query_hash => params)
end
def set_default_options(options)
      options.reverse_merge!({
        :report => 'Dashboard',
        :from    => a_month_ago,
        :to      => today,
        :tab     => 0,
        :format => FORMAT_CSV,
        :rows    => 50,
        :compute => 'average',
        :gdfmt   => 'nth_day',
        :view    => 0
      })
def convert_options_to_uri_params(options)
  params = {
        :pdr => quot;#{options[:from]}-
                   #{options[:to]}quot;,
        :rpt =>
             quot;#{options[:report]}Reportquot;,
        :cmp => options[:compute],
        :fmt => options[:format],
        :view => options[:view],
        :tab => options[:tab],
        :trows=> options[:rows],
        :gdfmt=> options[:gdfmt],
        :id   => profile_id
      }
> profile.report_names

=> [quot;ad_versions_reportquot;, quot;adwords_reportquot;,
quot;all_sources_reportquot;, quot;average_pageviews_reportquot;,
quot;bounce_rate_reportquot;,quot;browsers_reportquot;,quot;campaigns_reportquot;,
quot;colors_reportquot;, quot;content_by_title_reportquot;,
quot;content_drilldown_reportquot;, quot;content_reportquot;,
quot;dashboard_reportquot;, quot;depth_of_visit_reportquot;,
quot;direct_sources_reportquot;, quot;entrances_reportquot;,
quot;exits_reportquot;,quot;flash_reportquot;,quot;geo_map_reportquot;,quot;hostnames_
reportquot;,quot;java_reportquot;,quot;keyword_position_reportquot;,
quot;keywords_reportquot;,quot;languages_reportquot;,quot;length_of_visit_repo
rtquot;,quot;loyalty_reportquot;,quot;networks_reportquot;,quot;os_browsers_report
quot;,quot;pageviews_reportquot;,quot;platforms_reportquot;,quot;recency_reportquot;,quot;
referring_sources_reportquot;, quot;resolutions_reportquot;,
quot;search_engines_reportquot;,quot;speeds_reportquot;,quot;time_on_site_repo
rtquot;,quot;top_content_detail_keywords_reportquot;,quot;top_content_deta
il_navigation_reportquot;, quot;top_content_detail_path_reportquot;,
quot;top_content_detail_sources_reportquot;, quot;top_content_reportquot;,
quot;traffic_sources_reportquot;, quot;unique_visitors_reportquot;,
quot;visitor_types_reportquot;, quot;visitors_overview_reportquot;,
quot;visits_reportquot;]
it
worked
but




Photo: moriza http://flickr.com/photos/moriza/72551421/
English
UK
28 August 2008
US
quot;August 28, 2008quot;
UK
Page Views
item.page_views
US
Pageviews
item.pageviews
Italiano
28 agosto 2008
Pagine visualizzate
item.
pagine_visualizzate
Google: Settings ->
     Language:
choose UK English
OR
choose US English
Rug rat
  Photo: Ozyman http://flickr.com/photos/ozyman/465113688/
local server
http://localhost:8888/
top_content_detail_keywords
         ?url=/mps
serves json
def call(env)
  path = env['PATH_INFO'].tr('/','')
  request = Rack::Request.new(env)

  report_name = (path + '_report').to_sym
  params = request.GET.symbolize_keys

  report = @profile.send(report_name, params)

  data = { :report_name => report.name,
       :items => report.items}

  [200, {'Content-Type' =>
       quot;application/jsonquot;}, data.to_json ]
end
{
quot;report_namequot;:
  quot;Entrance Keywords:,/mpsquot;,

quot;itemsquot;: [
  {quot;bounce_ratequot;: quot;0.0quot;,
  quot;pageviewsquot;: quot;17quot;,
  quot;percentage_exitquot;: quot;0.058823529quot;,
  quot;time_on_pagequot;: quot;21.9375quot;,
  quot;dollar_indexquot;: quot;0.0quot;,
  quot;keywordquot;: quot;gordon copelandquot;,
  quot;unique_pageviewsquot;: quot;10quot;},
greasemonkey script
http://localhost:8888/
top_content_detail_keywords
         ?url=/mps
http://localhost:8888/
     keyword_detail?
keywords=party list mps nz
      &segment=city
http://localhost:8888/
     keyword_detail?
keywords=party list mps nz
  &segment=organization
Production?
Future?

  have fun!

  wrap an OS
analytics lib?
a lytics

github.com/robmckinnon

     rugalytics

        morph

More Related Content

What's hot

5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
nicdev
 

What's hot (18)

Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
 
Slimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en TruuksSlimme Joomla! Templating Tips en Truuks
Slimme Joomla! Templating Tips en Truuks
 
Clever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and TricksClever Joomla! Templating Tips and Tricks
Clever Joomla! Templating Tips and Tricks
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Building Robust jQuery Plugins
Building Robust jQuery PluginsBuilding Robust jQuery Plugins
Building Robust jQuery Plugins
 
Alfresco Forms Service Deep Dive
Alfresco Forms Service Deep DiveAlfresco Forms Service Deep Dive
Alfresco Forms Service Deep Dive
 
PLAT-14 Forms Config, Customization, and Extension
PLAT-14 Forms Config, Customization, and ExtensionPLAT-14 Forms Config, Customization, and Extension
PLAT-14 Forms Config, Customization, and Extension
 
User Behavior Tracking with Google Analytics, Garb, and Vanity
User Behavior Tracking with Google Analytics, Garb, and VanityUser Behavior Tracking with Google Analytics, Garb, and Vanity
User Behavior Tracking with Google Analytics, Garb, and Vanity
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 
Mechanize at the Ruby Drink-up of Sophia, November 2011
Mechanize at the Ruby Drink-up of Sophia, November 2011Mechanize at the Ruby Drink-up of Sophia, November 2011
Mechanize at the Ruby Drink-up of Sophia, November 2011
 
Make Your Own Damn SEO Tools (Using Google Docs!)
Make Your Own Damn SEO Tools (Using Google Docs!)Make Your Own Damn SEO Tools (Using Google Docs!)
Make Your Own Damn SEO Tools (Using Google Docs!)
 
Hacking with YUI
Hacking with YUIHacking with YUI
Hacking with YUI
 
Zend framework 04 - forms
Zend framework 04 - formsZend framework 04 - forms
Zend framework 04 - forms
 
Lecture n
Lecture nLecture n
Lecture n
 
Flickr Open Api Mashup
Flickr Open Api MashupFlickr Open Api Mashup
Flickr Open Api Mashup
 
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
浜松Rails3道場 其の壱 プロジェクト作成〜Rouging編
 
Google Talk: DOs and DON'Ts of Mobile Strategy
Google Talk: DOs and DON'Ts of Mobile StrategyGoogle Talk: DOs and DON'Ts of Mobile Strategy
Google Talk: DOs and DON'Ts of Mobile Strategy
 

Viewers also liked (6)

Now Playing
Now PlayingNow Playing
Now Playing
 
Vedanta at work-Surya Tahora-Complete Wellbeing June 2016
Vedanta at work-Surya Tahora-Complete Wellbeing June 2016Vedanta at work-Surya Tahora-Complete Wellbeing June 2016
Vedanta at work-Surya Tahora-Complete Wellbeing June 2016
 
Les Vampires 12 4 2009 1
Les Vampires  12 4 2009 1Les Vampires  12 4 2009 1
Les Vampires 12 4 2009 1
 
Une vie humaine gachée: chant dévotionnel vaisnava
Une vie humaine gachée: chant dévotionnel vaisnavaUne vie humaine gachée: chant dévotionnel vaisnava
Une vie humaine gachée: chant dévotionnel vaisnava
 
The HealthyLiving r-stinson1
The HealthyLiving r-stinson1The HealthyLiving r-stinson1
The HealthyLiving r-stinson1
 
Les festes de Nadal
Les festes de NadalLes festes de Nadal
Les festes de Nadal
 

Similar to Rugalytics | Ruby Manor Nov 2008

Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
Wen-Tien Chang
 
Rails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity PresentationRails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity Presentation
railsconf
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
Carles Farré
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
Yi-Ting Cheng
 

Similar to Rugalytics | Ruby Manor Nov 2008 (20)

Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
 
Facebook Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend Framework
 
Introduction to YQL - Talk at HackU 2010, IIT Chennai
Introduction to YQL - Talk at HackU 2010, IIT ChennaiIntroduction to YQL - Talk at HackU 2010, IIT Chennai
Introduction to YQL - Talk at HackU 2010, IIT Chennai
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
Django
DjangoDjango
Django
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
Opensocial Codelab
Opensocial CodelabOpensocial Codelab
Opensocial Codelab
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Yahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from InternetYahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from Internet
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Rails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity PresentationRails 3 And The Real Secret To High Productivity Presentation
Rails 3 And The Real Secret To High Productivity Presentation
 
Struts2
Struts2Struts2
Struts2
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (3/3)
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 

Recently uploaded

Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
FIDO Alliance
 

Recently uploaded (20)

Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Navigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi DaparthiNavigating the Large Language Model choices_Ravi Daparthi
Navigating the Large Language Model choices_Ravi Daparthi
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 

Rugalytics | Ruby Manor Nov 2008