承認が必要です
ユーザーがアクセスできるカスタム指標を取得します。 こちらから今すぐお試しいただけます。または、例をご覧ください。
リクエスト
HTTP リクエスト
GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customMetrics/customMetricId
パラメータ
パラメータ名 | 値 | 説明 |
---|---|---|
パスパラメータ | ||
accountId |
string |
取得するカスタム指標のアカウント ID。 |
customMetricId |
string |
取得するカスタム指標の ID。 |
webPropertyId |
string |
取得するカスタム指標のウェブ プロパティ ID。 |
承認
このリクエストは、少なくとも以下のスコープの 1 つによって承認される必要があります(詳細については、認証と承認に関する記事をご覧ください)。
スコープ |
---|
https://www.googleapis.com/auth/analytics.edit |
https://www.googleapis.com/auth/analytics.readonly |
リクエスト本文
このメソッドをリクエストの本文に含めないでください。
レスポンス
成功すると、このメソッドによって、management.customMetric リソースを含むレスポンス本文が返されます。
例
注: このメソッドのコード例は、サポートされているすべてのプログラミング言語での例を示しているわけではありません(サポート対象の言語の一覧は、クライアント ライブラリ ページをご覧ください)。
Java
Java クライアント ライブラリを使用します。
/* * Note: This code assumes you have an authorized Analytics service object. */ /* * This request gets an existing custom metric. */ try { CustomMetric = analytics.management().customMetrics() .get("123456", "UA-123456-1", "ga:metric2").execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); }
Python
Python クライアント ライブラリを使用します。
# Note: This code assumes you have an authorized Analytics service object. # This request gets an existing custom metric. try: metric = analytics.management().customMetrics().get( accountId='123456', webPropertyId='UA-123456-1', customMetricId='ga:metric2' ).execute() except TypeError, error: # Handle errors in constructing a query. print 'There was an error in constructing your query : %s' % error except HttpError, error: # Handle API errors. print ('There was an API error : %s : %s' % (error.resp.status, error.resp.reason))
試してみる
リアルタイムのデータでこのメソッドを呼び出してレスポンスを確認するには、以下の APIs Explorer か、 スタンドアロンの テストツール をご利用ください。