このガイドでは、Google Ads API を使って作成できるさまざまなタイプのコンバージョン アクションのリスト、これらのアクションを Google 広告の管理画面にマッピングする方法、新しいコンバージョン アクションの作成方法を示す詳細なコードサンプルを紹介します。
コンバージョンを測定するには、トラッキングするコンバージョン アクションの type
に ConversionAction
を設定します。たとえば、オンライン購入と電話での問い合わせには、それぞれ異なるコンバージョン アクションが必要です。
API で新しいコンバージョン アクションを設定する場合は、以下の「コンバージョン アクションを追加する」サンプルコードを使用することをおすすめします。このサンプルでは、すべてのバックグラウンド認証タスクが自動的に処理され、ConversionAction
の作成手順が示されます。
また、ほとんどのコンバージョン アクションについては、トラッキングするための追加手順が必要です。たとえば、ウェブサイトでのコンバージョンをトラッキングするには、タグと呼ばれるコード スニペットをウェブサイトのコンバージョン ページに追加する必要があります。コンバージョン アクションに関するその他の要件については、ヘルプセンターの記事をご覧ください。
ウェブサイト コンバージョン
ウェブサイト コンバージョンを使用すると、オンライン販売、リンクのクリック、ページビュー、登録などのウェブサイトでのアクションをトラッキングできます。
ウェブサイトでコンバージョンをトラッキングするには、ConversionActionType
を WEBPAGE
に設定して ConversionAction
を作成し、タグと呼ばれるコード スニペットをウェブサイトのコンバージョン ページに追加する必要があります。
ConversionAction
には複数の種類のウェブサイト コンバージョンが含まれており、ConversionAction
の tag_snippets フィールドにリストされた各 TagSnippet
の type
フィールドによって API 内で区別されます。
TagSnippet
では、コンバージョン アクションをトラッキングするためにウェブサイトに追加する必要があるトラッキング コードを指定します。ウェブサイト コンバージョンと電話番号クリック コンバージョンでは、event_snippet
はコンバージョン アクションを示すウェブページ(購入手続きの確認やリードフォームの送信ページなど)に配置する必要があります。global_site_tag
はウェブサイトのすべてのページにインストールする必要があります。どちらの属性も、ConversionActionService
で取得できます。ページにタグを設定する方法について詳しくは、ヘルプセンターをご覧ください。
次の表は、Google 広告管理画面の各 [参照元] に使用する、対応する API パラメータを示したものです。
トラッキング コードの種類 | Google 広告ソース |
---|---|
WEBPAGE |
ウェブサイト、ウェブサイト(Google アナリティクス(GA4)) |
WEBPAGE_ONCLICK |
ウェブサイト、ウェブサイト(Google アナリティクス(GA4)) |
CLICK_TO_CALL |
電話番号のクリック数 |
--- |
ウェブサイト(Google アナリティクス(UA)) |
アプリ コンバージョン
アプリ コンバージョンを使用すると、モバイルアプリのインストールや Google Play ストアからのアプリ内購入をトラッキングできます。
次の表は、Google 広告のウェブ インターフェースの 参照元 で使用する同等の
ConversionActionType
API パラメータを示したものです。
コンバージョン アクションの種類 | Google 広告ソース |
---|---|
GOOGLE_PLAY_DOWNLOAD |
[Google Play] > [Installs] |
GOOGLE_PLAY_IN_APP_PURCHASE |
[Google Play] > [アプリ内購入] |
Google アナリティクス 4 プロパティまたは第三者アプリ分析を使用して、モバイルアプリの他のアクションをトラッキングする場合。詳しくは、その他のコンバージョン アクション タイプをご覧ください。
通話コンバージョン
通話コンバージョン トラッキングを使用すると、広告経由の通話数、ウェブサイトに掲載された電話番号への問い合わせ、モバイルサイトでの電話番号のクリック数をトラッキングできます。
次の表は、Google 広告のウェブ インターフェースの 参照元 で使用する同等の
ConversionActionType
API パラメータを示したものです。
コンバージョン アクションの種類 | Google 広告ソース |
---|---|
AD_CALL |
電話番号表示オプションを使用した広告や電話専用広告でのコール コンバージョン |
WEBSITE_CALL |
ウェブサイトに掲載した電話番号への問い合わせ |
CLICK_TO_CALL |
モバイルサイト上での電話番号のクリック数 |
CLICK_TO_CALL
タイプは AD_CALL
タイプと異なり、実際の通話はトラッキングしません。代わりに、CLICK_TO_CALL
はモバイル デバイスからの電話番号のクリックのみをトラッキングします。これは、Google 広告専用転送電話番号を使って通話をトラッキングできない場合に便利です。
AD_CALL
AD_CALL
コンバージョン アクションは、Google 広告の管理画面で広告経由の通話数コンバージョンとして表示されます。AD_CALL
コンバージョン アクションを作成したら、CallAsset
の作成時に call_conversion_action
フィールドにそのリソース名を指定します。電話番号アセットを使用すると、広告に電話番号を直接表示できます。
通話が指定の時間を超えた場合、コンバージョンとしてレポートされます。 カウントされます。
WEBSITE_CALL
WEBSITE_CALL
コンバージョン アクションは、Google 広告の管理画面で「ウェブサイト経由の通話数」コンバージョンとして表示されます。
AD_CALL
とは異なり、このトラッカーでは、ウェブサイトに掲載された電話番号の通話トラッキング用の動的な Google 広告専用転送電話番号を取得するために、event_snippet
と global_site_tag
をウェブサイトに追加する必要があります。また、電話番号アセットを設定し、ユーザー単位、キャンペーン単位、広告グループ単位でリンクする必要があります。
オフライン コンバージョンのインポート
次の表に、Google 広告の管理画面の各参照元の対応する ConversionActionType
API パラメータと、各コンバージョン アクション タイプに関するドキュメントへのリンクを示します。
コンバージョン アクションの種類 | Google 広告ソース | API 設定ガイド |
---|---|---|
UPLOAD_CLICKS |
クリックに起因するコンバージョンとリードの拡張コンバージョンをトラッキングします | クリックのアップロードに関するガイド
リードの拡張コンバージョンに関するガイド |
UPLOAD_CALLS |
電話での問い合わせによるコンバージョンをトラッキング | API 設定ガイド |
STORE_SALES |
店舗販売のコンバージョンをトラッキングする | API 設定ガイド |
拡張コンバージョン(ウェブ向け)
拡張コンバージョン(ウェブ向け)を使用すると、WEBPAGE
個のコンバージョン アクションのファーストパーティ コンバージョン データを、コンバージョン イベントの発生から 24 時間以内に同時ではなく、同時に送信できます。これにより、顧客データベースや CRM システムなど、さまざまなソースからファーストパーティ データを見つけることができます。
その他のコンバージョン アクションの種類
Google Ads API では、レポートで使用できるその他のタイプのコンバージョン アクションを作成できますが、これらのアクションの作成または変更については制限または禁止される場合があります。
SKAdNetwork コンバージョン
iOS アプリ キャンペーンを実施し、SKAdNetwork を実装している場合は、次のリソースを使用して、Customer
および Campaign
レベルで Google に提供された SKAdNetwork データにアクセスできます。
レポートのフィールド | 説明 |
---|---|
metrics.sk_ad_network_installs |
Apple から報告されたインストール数。この指標は、segments.sk_ad_network_conversion_value と日付関連のセグメントの任意の組み合わせでのみセグメント化できます。 |
metrics.sk_ad_network_total_conversions |
Apple によってレポートされたコンバージョンの合計数。これには、インストール数やその他のタイプのコンバージョンが含まれます。この指標は、SKAdNetwork 関連のセグメントと日付関連のセグメントでのみ分割できます。 |
segments.sk_ad_network_ad_event_type |
特定のコンバージョンで発生したイベントのタイプ。 |
segments.sk_ad_network_attribution_credit |
特定のコンバージョンの貢献度を割り当てる方法。 |
segments.sk_ad_network_fine_conversion_value |
Apple によってレポートされたコンバージョンの値。このセグメントは、 Apple が値 |
segments.sk_ad_network_coarse_conversion_value |
個々のコンバージョンの大まかな値。 |
segments.sk_ad_network_postback_sequence_index |
特定のコンバージョンのポストバックの位置(順序)。 |
segments.sk_ad_network_source_app.sk_ad_network_source_app_id |
iOS ストアキットの広告ネットワークのインストールを促進した広告が表示されたアプリ ID。 |
segments.sk_ad_network_source_domain |
iOS Store Kit 広告ネットワークのインストールを促進する広告が表示されたウェブサイト。値が null の場合、このセグメントが該当しない(iOS 以外のキャンペーンなど)、または Apple から送信されたポストバックに含まれていなかったことを意味します。 |
segments.sk_ad_network_source_type |
iOS ストアキットの広告ネットワークのインストールを促す広告が表示されたソースタイプ。値が null の場合、このセグメントが適用されないことを意味します(iOS 以外のキャンペーンなど)。または、Apple から送信されたポストバックにソースドメインもソースアプリも含まれていなかったことを意味します。 |
segments.sk_ad_network_user_type |
特定のコンバージョンを発生させたユーザーのタイプ。 |
segments.sk_ad_network_redistributed_fine_conversion_value |
このセグメントのコンバージョン値には、コンバージョン値に再分配された null 値が含まれています。このセグメントは、Apple から返された正確なコンバージョン値と、Google から推定された null 値の合計を表します。 |
CustomerSkAdNetworkConversionValueSchema
を使用して、iOS アプリを使用している特定のリンク済みユーザーの SKAdNetwork コンバージョン値のマッピングを保存することもできます。
Python サンプルコード
#!/usr/bin/env python # Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import sys from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException def main(client, customer_id): """Adds a keyword plan, campaign, ad group, etc. to the customer account. Also handles errors from the API and prints them. Args: client: An initialized instance of GoogleAdsClient customer_id: A str of the customer_id to use in requests. """ res = update_skan_cv_schema( client, customer_id, "my_app_id", "account_link_id" ) print(res) def update_skan_cv_schema(client, customer_id, app_id, account_link_id): skan_service = client.get_service( "CustomerSkAdNetworkConversionValueSchemaService" ) req = client.get_type( "MutateCustomerSkAdNetworkConversionValueSchemaRequest" ) operation = client.get_type( "CustomerSkAdNetworkConversionValueSchemaOperation" ) schema_instance = client.get_type( "CustomerSkAdNetworkConversionValueSchema" ) new_schema = operation.update new_schema.resource_name = ( skan_service.customer_sk_ad_network_conversion_value_schema_path( "customer_id", "account_link_id" ) ) new_schema.schema.app_id = app_id new_schema.schema.measurement_window_hours = 48 skan_cv_mapping = ( schema_instance.SkAdNetworkConversionValueSchema.FineGrainedConversionValueMappings() ) skan_cv_mapping.fine_grained_conversion_value = 0 # 0 - 63 skan_cv_mapping.conversion_value_mapping.min_time_post_install_hours = 0 skan_cv_mapping.conversion_value_mapping.max_time_post_install_hours = 48 skan_cv_event = schema_instance.SkAdNetworkConversionValueSchema.Event() skan_cv_event.mapped_event_name = "TEST" skan_cv_event.event_revenue_value = 10 skan_cv_mapping.conversion_value_mapping.mapped_events.append(skan_cv_event) new_schema.schema.fine_grained_conversion_value_mappings.append( skan_cv_mapping ) req.operation = operation req.customer_id = customer_id res = skan_service.mutate_customer_sk_ad_network_conversion_value_schema( req ) return res if __name__ == "__main__": # GoogleAdsClient will read the google-ads.yaml configuration file in the # home directory if none is specified. googleads_client = GoogleAdsClient.load_from_storage( version="v17" ) parser = argparse.ArgumentParser( description="Creates a keyword plan for specified customer." ) # The following argument(s) should be provided to run the example. parser.add_argument( "-c", "--customer_id", type=str, required=True, help="The Google Ads customer ID.", ) args = parser.parse_args() try: main(googleads_client, args.customer_id) except GoogleAdsException as ex: print( f'Request with ID "{ex.request_id}" failed with status ' f'"{ex.error.code().name}" and includes the following errors:' ) for error in ex.failure.errors: print(f'\tError with message "{error.message}".') if error.location: for field_path_element in error.location.field_path_elements: print(f"\t\tOn field: {field_path_element.field_name}") sys.exit(1)
Google アナリティクス
リンクされた Google アナリティクス プロパティのコンバージョンには、次のいずれかの type
値が含まれます。
GA4 プロパティの変換:
GOOGLE_ANALYTICS_4_CUSTOM
GOOGLE_ANALYTICS_4_PURCHASE
google_analytics_4_settings
フィールドから GA4 プロパティ ID、プロパティ名、イベント名を取得することもできます。ユニバーサル アナリティクス プロパティの変換:
UNIVERSAL_ANALYTICS_GOAL
UNIVERSAL_ANALYTICS_TRANSACTION
GA4 プロパティのコンバージョンには、次の変更を加えることができます。
status
フィールドをHIDDEN
からENABLED
に変更して、GA4 プロパティから Google 広告アカウントにコンバージョンをインポートします。primary_for_goal
フィールドとcategory
フィールドを変更して、Google 広告の入札とレポートへの影響を指定します。name
またはvalue_settings
を更新します。remove
オペレーションを使用して、Google 広告アカウントからコンバージョンを削除します。
インポートした GA4 コンバージョンの他の属性や、インポートした UA コンバージョンのいずれかの属性を変更しようとすると、MUTATE_NOT_ALLOWED
エラーが発生します。これらの変更は、Google 広告の管理画面からのみ行えます。
Firebase と第三者のアプリ分析
第三者アプリ分析または Firebase のコンバージョンをインポートするには、ConversionActionService
の mutate
メソッドを使用して、ConversionAction
の status
を HIDDEN
から ENABLED
に変更します。これらのコンバージョン アクションでは、app_id
の更新はサポートされていません。
FIREBASE_ANDROID_FIRST_OPEN
FIREBASE_ANDROID_IN_APP_PURCHASE
FIREBASE_ANDROID_CUSTOM
FIREBASE_IOS_FIRST_OPEN
FIREBASE_IOS_IN_APP_PURCHASE
FIREBASE_IOS_CUSTOM
THIRD_PARTY_APP_ANALYTICS_ANDROID_FIRST_OPEN
THIRD_PARTY_APP_ANALYTICS_ANDROID_IN_APP_PURCHASE
THIRD_PARTY_APP_ANALYTICS_ANDROID_CUSTOM
THIRD_PARTY_APP_ANALYTICS_IOS_FIRST_OPEN
THIRD_PARTY_APP_ANALYTICS_IOS_IN_APP_PURCHASE
THIRD_PARTY_APP_ANALYTICS_IOS_CUSTOM
ショップでの販売
Google Ads API を使って「STORE_SALES
」または「STORE_SALES_DIRECT_UPLOAD
」コンバージョン アクションを作成することはできませんが、この API では店舗販売取引のアップロードはサポートされています。
STORE_SALES
STORE_SALES_DIRECT_UPLOAD
その他
次のコンバージョン アクション タイプは Google Ads API では読み取り専用で、レポート用に提供されています。
ANDROID_APP_PRE_REGISTRATION
ANDROID_INSTALLS_ALL_OTHER_APPS
FLOODLIGHT_ACTION
FLOODLIGHT_TRANSACTION
GOOGLE_HOSTED
LEAD_FORM_SUBMIT
SALESFORCE
SEARCH_ADS_360
SMART_CAMPAIGN_AD_CLICKS_TO_CALL
SMART_CAMPAIGN_MAP_CLICKS_TO_CALL
SMART_CAMPAIGN_MAP_DIRECTIONS
SMART_CAMPAIGN_TRACKED_CALLS
STORE_VISITS
WEBPAGE_CODELESS
不明
Google 広告アカウントに他の種類のコンバージョン アクションが含まれている場合、クエリとレポートでは、ConversionAction.type
が UNKNOWN
のコンバージョン アクションが返されることがあります。この API では、これらのコンバージョン アクションの管理はサポートされていませんが、metrics.conversions
や metrics.conversions_value
などの主要なコンバージョン指標の完全な結果を提供するためにレポートで返されます。
サンプルコード
次のコードサンプルは、新しいコンバージョン アクションを作成する手順を示しています。具体的には、type
が UPLOAD_CLICKS
に設定されたコンバージョン アクションを作成します。これは、[インポート] > [API またはアップロードを使用して手動でインポート] > [クリック経由のコンバージョンをトラッキング] を使用して新しいコンバージョン アクションを作成するのと同じ流れです。また、category
を DEFAULT
に設定します。
次のデフォルト設定が適用されます。
primary_for_goal
フィールドは Google Ads API で自動的に設定されますが、このフィールドを明示的に設定することで、コンバージョン目標と組み合わせたコンバージョン アクションがアカウントのレポートと入札に与える影響を管理できます。Google Ads API では、
counting_type
が自動的にMANY_PER_CLICK
に設定されます。詳しくは、コンバージョンのカウント方法についてをご覧ください。Google Ads API は、
attribution_model_settings
フィールドをAttributionModel
のGOOGLE_SEARCH_ATTRIBUTION_DATA_DRIVEN
値に設定することで、アトリビューション モデルをデータドリブンに設定します。
Java
private void runExample(GoogleAdsClient googleAdsClient, long customerId) { // Creates a ConversionAction. ConversionAction conversionAction = ConversionAction.newBuilder() // Note that conversion action names must be unique. If a conversion action already // exists with the specified conversion_action_name the create operation will fail with // a ConversionActionError.DUPLICATE_NAME error. .setName("Earth to Mars Cruises Conversion #" + getPrintableDateTime()) .setCategory(ConversionActionCategory.DEFAULT) .setType(ConversionActionType.WEBPAGE) .setStatus(ConversionActionStatus.ENABLED) .setViewThroughLookbackWindowDays(15L) .setValueSettings( ValueSettings.newBuilder() .setDefaultValue(23.41) .setAlwaysUseDefaultValue(true) .build()) .build(); // Creates the operation. ConversionActionOperation operation = ConversionActionOperation.newBuilder().setCreate(conversionAction).build(); try (ConversionActionServiceClient conversionActionServiceClient = googleAdsClient.getLatestVersion().createConversionActionServiceClient()) { MutateConversionActionsResponse response = conversionActionServiceClient.mutateConversionActions( Long.toString(customerId), Collections.singletonList(operation)); System.out.printf("Added %d conversion actions:%n", response.getResultsCount()); for (MutateConversionActionResult result : response.getResultsList()) { System.out.printf( "New conversion action added with resource name: '%s'%n", result.getResourceName()); } } }
C#
public void Run(GoogleAdsClient client, long customerId) { // Get the ConversionActionService. ConversionActionServiceClient conversionActionService = client.GetService(Services.V17.ConversionActionService); // Note that conversion action names must be unique. // If a conversion action already exists with the specified name the create operation // will fail with a ConversionAction.DUPLICATE_NAME error. string ConversionActionName = "Earth to Mars Cruises Conversion #" + ExampleUtilities.GetRandomString(); // Add a conversion action. ConversionAction conversionAction = new ConversionAction() { Name = ConversionActionName, Category = ConversionActionCategory.Default, Type = ConversionActionType.Webpage, Status = ConversionActionStatus.Enabled, ViewThroughLookbackWindowDays = 15, ValueSettings = new ConversionAction.Types.ValueSettings() { DefaultValue = 23.41, AlwaysUseDefaultValue = true } }; // Create the operation. ConversionActionOperation operation = new ConversionActionOperation() { Create = conversionAction }; try { // Create the conversion action. MutateConversionActionsResponse response = conversionActionService.MutateConversionActions(customerId.ToString(), new ConversionActionOperation[] { operation }); // Display the results. foreach (MutateConversionActionResult newConversionAction in response.Results) { Console.WriteLine($"New conversion action with resource name = " + $"'{newConversionAction.ResourceName}' was added."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
PHP
public static function runExample(GoogleAdsClient $googleAdsClient, int $customerId) { // Creates a conversion action. $conversionAction = new ConversionAction([ // Note that conversion action names must be unique. // If a conversion action already exists with the specified conversion_action_name // the create operation will fail with a ConversionActionError.DUPLICATE_NAME error. 'name' => 'Earth to Mars Cruises Conversion #' . Helper::getPrintableDatetime(), 'category' => ConversionActionCategory::PBDEFAULT, 'type' => ConversionActionType::WEBPAGE, 'status' => ConversionActionStatus::ENABLED, 'view_through_lookback_window_days' => 15, 'value_settings' => new ValueSettings([ 'default_value' => 23.41, 'always_use_default_value' => true ]) ]); // Creates a conversion action operation. $conversionActionOperation = new ConversionActionOperation(); $conversionActionOperation->setCreate($conversionAction); // Issues a mutate request to add the conversion action. $conversionActionServiceClient = $googleAdsClient->getConversionActionServiceClient(); $response = $conversionActionServiceClient->mutateConversionActions( MutateConversionActionsRequest::build($customerId, [$conversionActionOperation]) ); printf("Added %d conversion actions:%s", $response->getResults()->count(), PHP_EOL); foreach ($response->getResults() as $addedConversionAction) { /** @var ConversionAction $addedConversionAction */ printf( "New conversion action added with resource name: '%s'%s", $addedConversionAction->getResourceName(), PHP_EOL ); } }
Python
def main(client, customer_id): conversion_action_service = client.get_service("ConversionActionService") # Create the operation. conversion_action_operation = client.get_type("ConversionActionOperation") # Create conversion action. conversion_action = conversion_action_operation.create # Note that conversion action names must be unique. If a conversion action # already exists with the specified conversion_action_name, the create # operation will fail with a ConversionActionError.DUPLICATE_NAME error. conversion_action.name = f"Earth to Mars Cruises Conversion {uuid.uuid4()}" conversion_action.type_ = ( client.enums.ConversionActionTypeEnum.UPLOAD_CLICKS ) conversion_action.category = ( client.enums.ConversionActionCategoryEnum.DEFAULT ) conversion_action.status = client.enums.ConversionActionStatusEnum.ENABLED conversion_action.view_through_lookback_window_days = 15 # Create a value settings object. value_settings = conversion_action.value_settings value_settings.default_value = 15.0 value_settings.always_use_default_value = True # Add the conversion action. conversion_action_response = ( conversion_action_service.mutate_conversion_actions( customer_id=customer_id, operations=[conversion_action_operation], ) ) print( "Created conversion action " f'"{conversion_action_response.results[0].resource_name}".' )
Ruby
def add_conversion_action(customer_id) # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new # Add a conversion action. conversion_action = client.resource.conversion_action do |ca| ca.name = "Earth to Mars Cruises Conversion #{(Time.new.to_f * 100).to_i}" ca.type = :UPLOAD_CLICKS ca.category = :DEFAULT ca.status = :ENABLED ca.view_through_lookback_window_days = 15 # Create a value settings object. ca.value_settings = client.resource.value_settings do |vs| vs.default_value = 15 vs.always_use_default_value = true end end # Create the operation. conversion_action_operation = client.operation.create_resource.conversion_action(conversion_action) # Add the ad group ad. response = client.service.conversion_action.mutate_conversion_actions( customer_id: customer_id, operations: [conversion_action_operation], ) puts "New conversion action with resource name = #{response.results.first.resource_name}." end
Perl
sub add_conversion_action { my ($api_client, $customer_id) = @_; # Note that conversion action names must be unique. # If a conversion action already exists with the specified conversion_action_name, # the create operation fails with error ConversionActionError.DUPLICATE_NAME. my $conversion_action_name = "Earth to Mars Cruises Conversion #" . uniqid(); # Create a conversion action. my $conversion_action = Google::Ads::GoogleAds::V17::Resources::ConversionAction->new({ name => $conversion_action_name, category => DEFAULT, type => WEBPAGE, status => ENABLED, viewThroughLookbackWindowDays => 15, valueSettings => Google::Ads::GoogleAds::V17::Resources::ValueSettings->new({ defaultValue => 23.41, alwaysUseDefaultValue => "true" })}); # Create a conversion action operation. my $conversion_action_operation = Google::Ads::GoogleAds::V17::Services::ConversionActionService::ConversionActionOperation ->new({create => $conversion_action}); # Add the conversion action. my $conversion_actions_response = $api_client->ConversionActionService()->mutate({ customerId => $customer_id, operations => [$conversion_action_operation]}); printf "New conversion action added with resource name: '%s'.\n", $conversion_actions_response->{results}[0]{resourceName}; return 1; }
この例は、クライアント ライブラリの リマーケティング フォルダと、コードサンプル コレクション「コンバージョン アクションのコードサンプルを追加する」にも格納されています。
確認事項
Google 広告と Google Ads API ではさまざまなコンバージョン アクションがサポートされているため、一部の検証ルールはアクションの type
によって異なります。
コンバージョン アクションの作成時に最もよくあるエラーは、DUPLICATE_NAME
です。コンバージョン アクションごとに一意の名前を使用してください。
ConversionAction
フィールドの設定に関するヒントは次のとおりです。
- すべての列挙型フィールド
- 列挙型フィールドを
UNKNOWN
に設定しようとすると、RequestError.INVALID_ENUM_VALUE
エラーが発生します。 app_id
app_id
属性は変更できず、新しいアプリ コンバージョンを作成する場合にのみ設定できます。attribution_model_settings
- これを非推奨オプションに設定すると、
CANNOT_SET_RULE_BASED_ATTRIBUTION_MODELS
エラーが発生します。Google 広告は、GOOGLE_ADS_LAST_CLICK
とGOOGLE_SEARCH_ATTRIBUTION_DATA_DRIVEN
のみをサポートしています。 click_through_lookback_window_days
この属性を許容範囲外の値に設定すると、
RangeError.TOO_LOW
またはRangeError.TOO_HIGH
エラーが発生します。この属性は、
AD_CALL
またはWEBSITE_CALL
のコンバージョン アクションの場合、[1,60]
の範囲内になければなりません。他のほとんどのコンバージョン アクションで指定できる範囲は[1,30]
です。include_in_conversions_metric
create
オペレーションまたはupdate
オペレーションでこの値を設定すると、FieldError.IMMUTABLE_FIELD
エラーで失敗します。代わりに、コンバージョン目標ガイドの説明に沿ってprimary_for_goal
を設定します。phone_call_duration_seconds
通話用ではないコンバージョン アクションにこの属性を設定しようとすると、
FieldError.VALUE_MUST_BE_UNSET
エラーが発生します。type
type
属性は変更できず、新しいコンバージョンを作成する場合にのみ設定できます。type
がUNKNOWN
と等しいコンバージョン アクションを更新すると、MutateError.MUTATE_NOT_ALLOWED
エラーが発生します。value_settings
WEBSITE_CALL
またはAD_CALL
のコンバージョン アクションのvalue_settings
では、always_use_default_value
をtrue
に設定する必要があります。この値を作成または更新するときにfalse
を指定すると、INVALID_VALUE
エラーが発生します。view_through_lookback_window_days
この属性を許容範囲外の値に設定すると、
RangeError.TOO_LOW
またはRangeError.TOO_HIGH
エラーが発生します。ほとんどのコンバージョン アクションで指定できる範囲は[1,30]
です。この属性は、
AD_CALL
またはWEBSITE_CALL
のコンバージョン アクションには設定できません。値を指定すると、VALUE_MUST_BE_UNSET
エラーが発生します。