承認が必要です
既存のカスタム指標を更新します。 こちらから今すぐお試しいただけます。または、例をご覧ください。
リクエスト
HTTP リクエスト
PUT https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customMetrics/customMetricId
パラメータ
パラメータ名 | 値 | 説明 |
---|---|---|
パスパラメータ | ||
accountId |
string |
更新するカスタム指標のアカウント ID。 |
customMetricId |
string |
更新するカスタム指標のカスタム指標 ID。 |
webPropertyId |
string |
更新するカスタム指標のウェブ プロパティ ID。 |
省略可能なクエリ パラメータ | ||
ignoreCustomDataSourceLinks |
boolean |
更新を強制的に実行し、カスタム データソースまたはカスタム データセットにリンクされたカスタム指標に関する警告を無視します(デフォルト値は false )。 |
承認
このリクエストには、次のスコープの承認が必要です(詳細については、認証と承認に関する記事をご覧ください)。
スコープ |
---|
https://www.googleapis.com/auth/analytics.edit |
リクエスト本文
リクエスト本文に、management.customMetric リソースを含めます。
レスポンス
成功すると、このメソッドによって、management.customMetric リソースを含むレスポンス本文が返されます。
例
注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。
Java
Java クライアント ライブラリを使用します。
/* * Note: This code assumes you have an authorized Analytics service object. */ /* * This request updates an existing custom metric. */ // Construct the body of the request and set its properties. CustomMetric body = new CustomMetric(); body.setName("Level Completions"); body.setScope("HIT"); body.setType("INTEGER"); body.setActive(true); try { analytics.management().customMetrics() .update("123456", "UA-123456-1", "ga:metric2", body).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 updates an existing custom metric. try: analytics.management().customMetrics().update( accountId='123456', webPropertyId='UA-123456-1', customMetricId='ga:metric2', body={ 'name': 'Level Completions', 'scope': 'HIT', 'type': 'INTEGER', 'active': True } ).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 か、スタンドアロンのテストツールをご利用ください。