既存のコンバージョンを変更する

Conversion.update() メソッドを呼び出して、1 つ以上の既存のコンバージョンに次の種類の変更を加えます。

検索広告 360 では、次の項目の変更はサポートされていません。

  • コンバージョンの日付。
  • コンバージョンの種類。
  • コンバージョンに結び付けられたキーワード、広告、訪問。
  • Floodlight アクティビティまたはアクティビティ名。

ただし、いつでも既存のコンバージョンを「削除済み」としてマークし、更新した日付、タイプ、アトリビューション ID、または Floodlight アクティビティで新しいコンバージョンをアップロードすることができます(必ず新しい conversionId も指定してください)。

Conversion.insert() と同様に、更新リクエストで複数のコンバージョンが指定されている場合、検索広告 360 はバッチ全体をオール オア ナッシング トランザクションとして更新するのではなく、ベスト エフォート ベースで各コンバージョンの更新を試みます。バッチ内の一部の更新が失敗しても、他の更新は引き続き成功する可能性があります。コンバージョンが更新されるたびにレスポンスを読み取り、更新が成功したかどうかを確認することをおすすめします。

更新リクエストを送信する

Conversion.update() で指定するフィールドのほとんどは、更新するコンバージョンを識別するために使用されます。既存のコンバージョンは、次のいずれかの方法で識別できます。

  • コンバージョンの clickId を指定します。
    • 編集するコンバージョンは、クリック ID の生成から 60 日以内に行う必要があります。
  • コンバージョンの criterionId(キーワード ID)を指定する

どちらの方法でも、コンバージョンの conversionIdconversionTimestamp、トランザクション type を指定する必要があります。

また、元のコンバージョンで revenueMicroscurrencyCode または quantityMillis が指定されていた場合、データを変更していない場合でも、更新リクエストでこのデータを指定する必要があります。

クリック ID でコンバージョンを特定する

コンバージョンで最初にクリック ID が指定されていた場合は、次のフィールドを指定して Conversion.update() リクエストを送信できます。

  • clickId
  • conversionId
  • conversionTimestamp
  • type
  • state(状態を REMOVED または ACTIVE に変更する場合にのみ必要)
  • quantityMillis(元のコンバージョンで指定されている場合のみ)
  • revenueMicros(元のコンバージョンで指定されている場合のみ)
  • currencyCode(元のコンバージョンで指定されている場合のみ)

既存の 2 つのコンバージョンの例を次に示します。

{
 "kind": "doubleclicksearch#conversionList",
  "conversion" : [{
    "clickId" : "COiYmPDTv7kCFcP0KgodOzQAAA",
    "conversionId" : "test_20130906_10",
    "conversionTimestamp" : "1378710000000",
    "segmentationType" : "FLOODLIGHT",
    "segmentationName" : "Test",
    "type": "TRANSACTION",
    "revenueMicros": "100000000", // 100 million revenueMicros is equivalent to $100 of revenue
    "currencyCode": "USD"
  },
  {
   "clickId": "COiYmPDTv7kCFcP0KgodOzQAAA",
   "conversionId": "test_1383337059137",
   "conversionTimestamp": "1378710000000",
   "segmentationType" : "FLOODLIGHT",
   "segmentationName" : "Test",
   "type": "ACTION",
   "quantityMillis": "1000"
  }]
}     

次のリクエストでは、前の例のコンバージョンの 1 つを更新し、もう 1 つのコンバージョンを削除します。

JSON

Conversion.update() リクエストでは PUT HTTP メソッドを使用します。

PUT https://www.googleapis.com/doubleclicksearch/v2/conversion
Authorization: Bearer your OAuth 2.0 access token
Content-type: application/json
{
 "kind": "doubleclicksearch#conversionList",
 "conversion": [
  {
   "clickId": "COiYmPDTv7kCFcP0KgodOzQAAA", // Replace with data from your site
   "conversionId": "test_20130906_10",
   "conversionTimestamp": "1378710000000",
   "type": "TRANSACTION",
   "revenueMicros": "90000000", // 90 million revenueMicros is equivalent to $90 of revenue
   "currencyCode": "USD"
  },
  {
   "clickId": "COiYmPDTv7kCFcP0KgodOzQAAA", // Replace with data from your site
   "conversionId": "test_1383337059137",
   "conversionTimestamp": "1378710000000",
   "type": "ACTION",
   "quantityMillis": "1000",
   "state": "REMOVED"
  }
 ]
}        

Java

/**
 * Instantiate the Doubleclicksearch service, create a conversion that updates an existing conversion,
 * and upload the conversions.
 */
public static void main(String[] args) throws Exception {

  Doubleclicksearch service = getService(); // See Set Up Your Application.

  // Set up a List to keep track of each conversion you create.
  List<Conversion> conversions = new Vector<Conversion>();

  // Create a conversion and add it to the conversion list.
  // Just to get a little fancy, the updateConversionFromVisit() method can be used for all
  // visit conversions, including conversions that don't specify quantity, revenue, or currency.
  // If quantityMillis wasn't specified in the original conversion, specify -1L for the
  // quantityMillis parameter. Likewise, if revenueMicros wasn't specified originally,
  // specify -1L for the revenueMicros parameter and an empty string for currency.
  conversionList = updateConversionFromVisit(
      conversionList,
      "COiYmPDTv7kCFcP0KgodOzQAAA", // clickId. Replace with data from your site
      "test_20130906_10",           // conversionId
      1378710000000L,               // timeStamp
      "TRANSACTION",                // type
      "",                           // state
      -1L,                          // quantityMillis
      90000000L,                    // revenueMicros. Equivalent to $90 of revenue
      "USD");                       // currencyCode

   // Here's a conversion that needs to be removed. Just set the state parameter to "REMOVED".
   conversionList = updateConversionFromVisit(
      conversionList,
      "COiYmPDTv7kCFcP0KgodOzQAAA", // clickId. Replace with data from your site
      "test_1383337059137",         // conversionId
      1378710000000L,               // timeStamp
      "ACTION",                     // type
      "REMOVED",                    // state
      1000L,                        // quantityMillis
      -1L,                          // revenueMicros
      "");                          // currencyCode

    // Upload the List and handle the response.
    uploadConversions(conversions, service); // See an example in Add New Conversions. 
  }

/**
 * Create a conversion and add it to a List<Conversion>.
 */
  private static List<Conversion> updateConversionFromVisit(List<Conversion> conversions,
      String clickId,
      String conversionId,
      Long timeStamp,
      String type,
      String state,
      Long quantity,
      Long revenue,
      String currency) {

    // Identifies the existing conversion.
    Conversion conversion = new Conversion()
        .setClickId(clickId)
        .setConversionId(conversionId)
        .setConversionTimestamp(BigInteger.valueOf(timeStamp))
        .setType(type);

    // Only add these fields if the value is not empty greater than -1.
    if(!state.isEmpty()) conversion.setState(state);
    if (quantity > -1L) {
      conversion.setQuantityMillis(quantity);
    }
    if (revenue > -1L) {
      conversion.setRevenueMicros(revenue);
      if (!currency.isEmpty()) {
        conversion.setCurrencyCode(currency);
      } else {
        System.err.println(String.format(
            "Can't add conversion %s. It specifies revenue but no currency.",
            conversion.getConversionId()));
        return conversions;
      }
    }

    conversions.add(conversion);
    return conversions;
  }         

Python

def update_conversion(service):
  """Change the revenue for one existing conversion and remove another.

  Args:
    service: An authorized Doubleclicksearch service. See Set Up Your Application.
  """
  request = service.conversion().update(
      body=
      {
          'conversion' : [{
              'clickId' : 'COiYmPDTv7kCFcP0KgodOzQAAA', // Replace with data from your site
              'conversionId' : 'test_20130906_13',
              'conversionTimestamp' : '1378710000000',
              'segmentationType' : 'FLOODLIGHT',
              'segmentationName' : 'Test',
              'type': 'TRANSACTION',
              'revenueMicros': '90000000', // 90 million revenueMicros is equivalent to $90 of revenue
              'currencyCode': 'USD'
            },
            {
             'clickId': 'COiYmPDTv7kCFcP0KgodOzQAAA', // Replace with data from your site
             'conversionId': 'test_1383337059137_01',
             'conversionTimestamp': '1378710000000',
             'segmentationType' : 'FLOODLIGHT',
             'segmentationName' : 'Test',
             'type': 'ACTION',
             'quantityMillis': '1000',
             'state': 'REMOVED'
            }]
      }
  )

  pprint.pprint(request.execute())

キーワード ID でコンバージョンを特定する

クリック ID にアクセスできない場合、またはコンバージョンが元々キーワード、キーワード、広告に関連付けられていた場合は、次のフィールドを指定して Conversion.update() リクエストを送信できます。

  • criterionId(キーワード ID)
  • conversionId
  • conversionTimestamp
  • type
  • state(状態を REMOVED または ACTIVE に変更する場合にのみ必要)
  • quantityMillis(元のコンバージョンで指定されている場合のみ)
  • revenueMicros(元のコンバージョンで指定されている場合のみ)
  • currencyCode(元のコンバージョンで指定されている場合のみ)

必要に応じて、コンバージョンの広告 ID やキャンペーン ID などの他の ID を指定することもできますが、必須ではありません。検索広告 360 で既存のコンバージョンを識別するために必要な ID は、上記のリストの ID のみです。

既存のコンバージョンの例を次に示します。

{
 "kind": "doubleclicksearch#conversionList",
  "conversion" : [{
   "agencyId": "12300000000000456",
   "advertiserId": "45600000000010291",
   "engineAccountId": "700000000042441",
   "campaignId": "71700000002044839",
   "adGroupId": "58700000032026064",
   "criterionId": "43700004289911004",
   "adId": "44700000155906860",
   "conversionId": "test_1383157519886",
   "conversionTimestamp": "1378710000000",
   "type": "ACTION",
   "quantityMillis": "1000",
   "segmentationType": "FLOODLIGHT",
   "segmentationName": "Test"
  }]
}     

次のリクエストでは、コンバージョンのタイムスタンプを更新します。

JSON

Conversion.update() リクエストでは PUT HTTP メソッドを使用します。

PUT https://www.googleapis.com/doubleclicksearch/v2/conversion
Authorization: Bearer your OAuth 2.0 access token
Content-type: application/json
{
 "kind": "doubleclicksearch#conversionList",
 "conversion": [
  {
   "criterionId": "43700004289911004", // Replace with your ID
   "conversionId": "test_1383157519886",
   "conversionTimestamp": "1378710000000",
   "type": "ACTION",
   "quantityMillis": "3000"
  }
 ]
}        

Java

    // Send conversion data to updateConversion, which creates a conversion and adds it
    // to the conversion list.
    conversionList =  updateConversionFromKeyword(conversionList,
        43700004289911004L,   // criterionId. Replace with your ID
        "test_1383157519886", // conversionId
        1378710000000L,       // timeStamp
        "ACTION",             // type
        "",                   // state
        3000L,                // quantityMillis
        -1L,                  // revenueMicros
        "");                  // currencyCode

  private static List<Conversion> updateConversionFromKeyword(List<Conversion> conversions,
       Long criterionId,
       String conversionId,
       Long timeStamp,
       String type,
       String state,
       Long quantity,
       Long revenue,
       String currency
    ) {

   Conversion conversion = new Conversion()
   .setCriterionId(criterionId)
   .setConversionId(conversionId)
   .setConversionTimestamp(BigInteger.valueOf(timeStamp))
   .setType(type);

   // Only add these fields if the value is not empty greater than -1.
   if(!state.isEmpty()) conversion.setState(state);
   if (quantity > -1L) {
     conversion.setQuantityMillis(quantity);
   }
   if (revenue > -1L) {
     conversion.setRevenueMicros(revenue);
     if (!currency.isEmpty()) {
       conversion.setCurrencyCode(currency);
     } else {
       System.err.println(String.format(
           "Can't add conversion %s. It specifies revenue but no currency.",
           conversion.getConversionId()));
       return conversions;
     }
   }

   conversions.add(conversion);
   return conversions;
   }                 

Python

def update_conversion(service):
  """Change the timestamp of a conversion. Use only the keyword id (criterionId)
  to identify the conversion.

  Args:
    service: An authorized Doubleclicksearch service. See Set Up Your Application.
  """
  request = service.conversion().update(
      body=
      {
          'conversion': [{
              'criterionId': '43700004289911004', // Replace with your ID
              'conversionId': 'test_1383157519886',
              'conversionTimestamp': '1378760000000',
              'type': 'ACTION',
              'quantityMillis': '1000'
            }]
      }
  )

  pprint.pprint(request.execute())

検索広告 360 のレスポンスを処理する

更新リクエストのレスポンスは、挿入リクエストのレスポンスと同じです。検索広告 360 は、リクエスト内のすべてのコンバージョンが正常に更新された場合にのみ成功を示します。

リクエストが成功した場合、レスポンスには、更新された各コンバージョンの完全な検索広告 360 内部表現(キャンペーン ID、広告グループ ID、キーワード(条件)ID など)が含まれます。

1 つ以上の更新が検証またはアップロードに失敗した場合、失敗した更新ごとに失敗メッセージがレスポンスに含まれます。レスポンスには、正常に更新されたコンバージョンに関するメッセージは含まれません。このエラー メッセージについて詳しくは、挿入リクエストの Search Ads 360 レスポンスを処理するをご覧ください。