認証が必要です
リクエスト
HTTP リクエスト
PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId/containers/containerId/rules/ruleId
パラメータ
パラメータ名 | 値 | 説明 |
---|---|---|
パスパラメータ | ||
accountId |
string |
GTM アカウント ID。 |
containerId |
string |
GTM コンテナ ID。 |
ruleId |
string |
GTM ルール ID。 |
省略可能なクエリ パラメータ | ||
fingerprint |
string |
指定する場合は、ストレージ内のルールのフィンガープリントと一致する必要があります。 |
承認
このリクエストは、次のスコープでの承認が必要です(認証と承認の詳細をご確認ください)。
スコープ |
---|
https://www.googleapis.com/auth/tagmanager.edit.containers |
リクエスト本文
リクエストの本文には、以下のプロパティを使用して Rules リソースを指定します。
プロパティ名 | 値 | 説明 | メモ |
---|---|---|---|
必須プロパティ | |||
condition[].parameter[] |
list |
条件の種類に応じた名前付きパラメータ(Key-Value)のリスト。備考:
|
書き込み可能 |
condition[].parameter[].type |
string |
パラメータの型。有効な値は次のとおりです。
有効な値は次のとおりです。
|
書き込み可能 |
condition[].type |
string |
この条件の演算子。
有効な値は次のとおりです。
|
書き込み可能 |
省略可能なプロパティ | |||
condition[] |
list |
このルールを構成する条件のリスト(条件は暗黙的に「AND」で連結)。 | 書き込み可能 |
condition[].parameter[].key |
string |
パラメータを一意に識別する名前付きキー。トップレベルのパラメータとマップ値では必須となります。リスト値では無視されます。 | 書き込み可能 |
condition[].parameter[].list[] |
list |
このリスト パラメータのパラメータ(キーは無視されます)。 | 書き込み可能 |
condition[].parameter[].map[] |
list |
このマップ パラメータのパラメータ(一意のキーが必要)。 | 書き込み可能 |
condition[].parameter[].value |
string |
指定された型のパラメータ値(「」などマクロの参照も使用できます)。 | 書き込み可能 |
name |
string |
ルールの表示名。 | 書き込み可能 |
notes |
string |
コンテナでこのルールを利用する方法についてのユーザーのメモ。 | 書き込み可能 |
レスポンス
成功すると、このメソッドによりレスポンスの本文で Rules リソースが返されます。
例
注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。
Java
Java クライアント ライブラリを使用します。
/* * Note: This code assumes you have an authorized tagmanager service object. */ /* * This request updates an existing rule for the authorized user. */ // Construct the condition parameters. Parameter arg0 = new Parameter(); arg0.setType("template"); arg0.setKey("arg0"); arg0.setValue("{{url}}"); Parameter arg1 = new Parameter(); arg1.setType("template"); arg1.setKey("arg1"); arg1.setValue(".*hellowworld.html"); // Construct the condition object Condition condition = new Condition(); condition.setType("endsWith"); condition.setParameter(Arrays.asList(arg0, arg1)); // Construct the rule object. Rule rule = new Rule(); rule.setName("Updated Rule"); rule.setCondition(Arrays.asList(condition)); try { Rule response = tagmanager.accounts().containers(). rules().update("123456", "54321", "2", rule).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } /* * The results of the update method are stored in the response object. * The following code shows how to access the updated name and fingerprint. */ System.out.println("Updated Name = " + response.getName()); System.out.println("Updated Fingerprint = " + response.getFingerprint());
Python
Python クライアント ライブラリを使用します。
# Note: This code assumes you have an authorized tagmanager service object. # This request updates an existing rule for the authorized user. try: response = tagmanager.accounts().containers().rules().update( accountId='123456', containerId='54321', ruleId='2', body={ 'name': 'Updated Ends with Rule', 'condition': [ { 'type': 'endsWith', 'parameter': [ { 'type': 'template', 'key': 'arg0', 'value': '{{url}}' }, { 'type': 'template', 'key': 'arg1', 'value': '.*hellowworld.html' } ] } ] } ).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)) # The results of the update method are stored in the response object. # The following code shows how to access the updated name and fingerprint. print 'Updated Name = %s' % response.get('name') print 'Updated Fingerprint = %s' % response.get('fingerprint')
試してみよう:
以下の API Explorer を使用して、ライブデータに対してこのメソッドを呼び出し、レスポンスを確認してください。