Rugalytics | Ruby Manor Nov 2008

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Rugalytics | Ruby Manor Nov 2008 - Presentation Transcript

    1. Rugalytics Photo: Archie McPhee Seattle http://flickr.com/photos/archiemcphee/1444560125/
    2. got
    3. website
    4. also
    5. Ruby API?
    6. jnunemaker
    7. Statwhore Photo: CARLOS62 http://flickr.com/photos/82887550@N00/352151895/
    8. logged in
    9. Analytics account
    10. grabbed
    11. <XML> reports
    12. <MiniTable id=\"BrowserMiniTable\"> <Row> <Cell> <Content> <Value>8,995</Value> </Content> </Cell> <Cell> <Content> <Value>70.79%</Value> </Content> </Cell> <PrimaryKey>IE</PrimaryKey> </Row> <Row>
    13. hardcoded
    14. accessors
    15. def pageviews end def visits end
    16. cool
    17. wanted
    18. MORE
    19. wanted
    20. to emerge class definitions from data at runtime Photo: brilarian http://flickr.com/photos/bybri/4443691/
    21. forked
    22. Statwhore
    23. kept
    24. login logic
    25. Google::Base
    26. grabbed
    27. C,S,V reports
    28. #----------------------- # BrowserMiniTable #----------------------- Browser,Visits,% visits IE,89950,0.70787754 Firefox,27980,0.22019359 Safari,5640,0.044384984
    29. made methods
    30. from data
    31. Morph Photo: Salt Fired http://www.flickr.com/photos/saltfired/201998836/
    32. module Rugalytics class Item include Morph
    33. def initialize labels, values
    34. labels.each_with_index do |label, index|
    35. attribute = normalize(label) value = values[index] morph(attribute, value)
    36. under the rug Photo: LizMarie http://flickr.com/photos/perspicacious/104917207/
    37. def morph_method_missing symbol,*args attribute = symbol.to_s.chomp '=' base.class_eval \"def #{attribute}; @#{attribute}; end; def #{attribute}=(value); @#{attribute} = value; end\" send(symbol, *args)
    38. > require 'ruby2ruby'
    39. > klass = Rugalytics::Item > y Ruby2Ruby.translate(klass)
    40. 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| ...
    41. controller
    42. def top_content days profile = Rugalytics.default_profile from_date = Date.today - days report = profile.top_content_report :from => from_date
    43. 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
    44. view
    45. %ul - @top_pages.each do |item| %li = link_to(item.page_title, item.url) %span.page_views =\"(#{item.unique_pageviews})\"
    46. lots of reports Photo: CloCkWeRX http://flickr.com/photos/clockwerx/9267076/
    47. def get_report_csv(options={}) options = set_default_options(options) params = convert_options_to_uri_params(options) self.class.get( \"https://google.com/analytics/ reporting/export\", :query_hash => params) end
    48. 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 })
    49. def convert_options_to_uri_params(options) params = { :pdr => \"#{options[:from]}- #{options[:to]}\", :rpt => \"#{options[:report]}Report\", :cmp => options[:compute], :fmt => options[:format], :view => options[:view], :tab => options[:tab], :trows=> options[:rows], :gdfmt=> options[:gdfmt], :id => profile_id }
    50. > profile.report_names => [\"ad_versions_report\", \"adwords_report\", \"all_sources_report\", \"average_pageviews_report\", \"bounce_rate_report\",\"browsers_report\",\"campaigns_report\", \"colors_report\", \"content_by_title_report\", \"content_drilldown_report\", \"content_report\", \"dashboard_report\", \"depth_of_visit_report\", \"direct_sources_report\", \"entrances_report\", \"exits_report\",\"flash_report\",\"geo_map_report\",\"hostnames_ report\",\"java_report\",\"keyword_position_report\", \"keywords_report\",\"languages_report\",\"length_of_visit_repo rt\",\"loyalty_report\",\"networks_report\",\"os_browsers_report \",\"pageviews_report\",\"platforms_report\",\"recency_report\",\" referring_sources_report\", \"resolutions_report\", \"search_engines_report\",\"speeds_report\",\"time_on_site_repo rt\",\"top_content_detail_keywords_report\",\"top_content_deta il_navigation_report\", \"top_content_detail_path_report\", \"top_content_detail_sources_report\", \"top_content_report\", \"traffic_sources_report\", \"unique_visitors_report\", \"visitor_types_report\", \"visitors_overview_report\", \"visits_report\"]
    51. it
    52. worked
    53. but Photo: moriza http://flickr.com/photos/moriza/72551421/
    54. English
    55. UK
    56. 28 August 2008
    57. US
    58. \"August 28, 2008\"
    59. UK
    60. Page Views
    61. item.page_views
    62. US
    63. Pageviews
    64. item.pageviews
    65. Italiano
    66. 28 agosto 2008
    67. Pagine visualizzate
    68. item. pagine_visualizzate
    69. Google: Settings -> Language:
    70. choose UK English
    71. OR
    72. choose US English
    73. Rug rat Photo: Ozyman http://flickr.com/photos/ozyman/465113688/
    74. local server
    75. http://localhost:8888/ top_content_detail_keywords ?url=/mps
    76. serves json
    77. 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' => \"application/json\"}, data.to_json ] end
    78. { \"report_name\": \"Entrance Keywords:,/mps\", \"items\": [ {\"bounce_rate\": \"0.0\", \"pageviews\": \"17\", \"percentage_exit\": \"0.058823529\", \"time_on_page\": \"21.9375\", \"dollar_index\": \"0.0\", \"keyword\": \"gordon copeland\", \"unique_pageviews\": \"10\"},
    79. greasemonkey script
    80. http://localhost:8888/ top_content_detail_keywords ?url=/mps
    81. http://localhost:8888/ keyword_detail? keywords=party list mps nz &segment=city
    82. http://localhost:8888/ keyword_detail? keywords=party list mps nz &segment=organization
    83. Production?
    84. Future? have fun! wrap an OS analytics lib?
    85. a lytics github.com/robmckinnon rugalytics morph

    + Rob Rob , 11 months ago

    custom

    1556 views, 1 favs, 2 embeds more stats

    Rugalytics - making a Ruby API to Google Analytics more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1556
      • 1554 on SlideShare
      • 2 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 37
    Most viewed embeds
    • 1 views on http://tmn-techblog.com
    • 1 views on http://localhost

    more

    All embeds
    • 1 views on http://tmn-techblog.com
    • 1 views on http://localhost

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories