Class: GaTrackable::PageViewsFetcher
- Inherits:
-
BaseFetcher
- Object
- BaseFetcher
- GaTrackable::PageViewsFetcher
- Defined in:
- lib/ga_trackable/page_views_fetcher.rb
Constant Summary
Constants inherited from BaseFetcher
Instance Attribute Summary
Attributes inherited from BaseFetcher
#end_date, #sometime_processed_counters, #start_date
Instance Method Summary collapse
- #counter_class ⇒ Object
-
#get_details_for(start_date: 1.year.ago, path:) ⇒ Object
Поулчить данные по просмотрам для конкретного пути.
Methods inherited from BaseFetcher
#fetch_for_current_day!, #initialize
Constructor Details
This class inherits a constructor from GaTrackable::BaseFetcher
Instance Method Details
#counter_class ⇒ Object
4 5 6 |
# File 'lib/ga_trackable/page_views_fetcher.rb', line 4 def counter_class GaTrackable::PageViewsCounter end |
#get_details_for(start_date: 1.year.ago, path:) ⇒ Object
Поулчить данные по просмотрам для конкретного пути. Используется в rake-таске.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ga_trackable/page_views_fetcher.rb', line 9 def get_details_for(start_date: 1.year.ago, path:) ga_start_date = start_date.strftime(GA_DATE_FORMAT) ga_end_date = DateTime.current.strftime(GA_DATE_FORMAT) data = @client.execute(api_method: @analytics.data.ga.get, parameters: { 'ids' => "ga:#{@config.view_id}", 'start-date' => ga_start_date, 'end-date' => ga_end_date, 'dimensions' => 'ga:pagePath,ga:pageTitle', 'metrics' => 'ga:uniquePageviews,ga:pageviews', 'sort' => 'ga:pagePath,ga:pageTitle', 'filters' => "ga:pagePath=@#{path}" }).data end |