lib/vanity/metric/google_analytics.rb
def google_analytics(web_property_id, *args)
      require "garb"
      options = Hash === args.last ? args.pop : {}
      metric = args.shift || :pageviews
      @ga_resource = Vanity::Metric::GoogleAnalytics::Resource.new(web_property_id, metric)
      @ga_mapper = options[:mapper] ||= lambda { |entry| entry.send(@ga_resource.metrics.elements.first).to_i }
      extend GoogleAnalytics
    rescue LoadError
      fail LoadError, "Google Analytics metrics require Garb, please gem install garb first"
    end
def google_analytics(web_property_id, *args)
      require "garb"
      options = Hash === args.last ? args.pop : {}
      metric = args.shift || :pageviews
      @ga_resource = Vanity::Metric::GoogleAnalytics::Resource.new(web_property_id, metric)
      @ga_mapper = options[:mapper] ||= lambda { |entry| entry.send(@ga_resource.metrics.elements.first).to_i }
      extend GoogleAnalytics
    rescue LoadError
      fail LoadError, "Google Analytics metrics require Garb, please gem install garb first"
    end
Use Google Analytics metric. Note: you must +require "garb"+ before
 vanity.

 @example Page views
   metric "Page views" do
     google_analytics "UA-1828623-6"
   end
 @example Visits
   metric "Visits" do
     google_analytics "UA-1828623-6", :visits
   end

 @since 1.3.0
 @see Vanity::Metric::GoogleAnalytics