0
を働いていません。
ここに私のコードです。
RailsのGAてCore Reporting APIのV4のorderBysは、私は、コアは、API V4を報告使用したGAから最も使用されるサイト内検索キーワードを取得しようとしています
require "google/apis/analyticsreporting_v4"
class GoogleAPI
def auth
Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: File.open(ENV['GOOGLE_AUTH_KEY_FILE']),
scope: 'https://www.googleapis.com/auth/analytics.readonly'
)
end
def popular_keywords
service = Google::Apis::AnalyticsreportingV4::AnalyticsReportingService.new
service.authorization = auth
query = {
view_id: ENV['POPULAR_KEYWORDS_GA_VIEW'],
dimensions: [{name: 'ga:searchKeyword'}],
metrics: [{expression: 'ga:searchUniques'}],
page_size: 1000,
orderBys: [{fieldName: 'ga:searchUniques', orderType: 'VALUE', sortOrder: 'DESCENDING'}],
date_ranges: [{start_date: '30daysAgo', end_date: 'today'}]
}
request = Google::Apis::AnalyticsreportingV4::GetReportsRequest.new
request.report_requests = [query]
reports = service.batch_get_reports request
p reports.to_h
[]
rescue => e
[]
end
end
期待通りにすべての作品は、それは寸法などのキーワードをフェッチし、評価指標として数値を使用しました。
しかし、orderBysは適用されません。 ga:searchUniques
で降順で注文する予定です。
ga:searchKeyword
(ディメンション)で昇順に注文されているようです。
誰でも助けてください。
ありがとうございました。