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

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Rugalytics | Ruby Manor Nov 2008