4.1.5 转化跟踪
价值和业务影响
为了有效地提供 Google 生态系统强大的机器学习技术和 对商家客户的广告系列进行分析,则需要进行转化 跟踪代码和再营销代码。
Google Ads 中的转化是指用户执行某项指定的操作 用户点击广告后,例如购买产品、安装移动应用 或注册电子邮件收件人列表。转化跟踪功能可提供重要的洞察信息 转化成用户的用户在浏览或点击广告后采取的操作,包括 计算和比较投资回报率 (ROI),帮助客户 决定应该将广告支出集中在哪些方面。跟踪还有助于确保 相应数据可用于对账订单会因 产品或类别,因此转化跟踪也可用于向您展示 特定的产品信息组正在转化为销售。
转化目标是指一组具有相同 基本目标。例如,“购买”可以是符合以下条件的转化目标: “网站购买”和“实体店销售”转化操作
转化操作仍用于跟踪转化情况和优化 广告系列。您创建转化操作,然后 Google 将其分组到转化中 目标。
购买转化操作
实施此处所述的转化跟踪后,商家可以 使用 Google Ads 账号来衡量购买转化次数和转化价值 。如果不启用转化跟踪,您将无法 从广告支出回报率的角度衡量广告系列带来的业务价值 广告支出)。还会发送其他数据信号,使广告系列能够 并优化广告效果。
其他转化操作
虽然只需要“购买”转化操作,但需要跟踪其他 转化操作可为您的商家提供额外的数据洞见。周三 建议您尽可能记录所有信息,同时尽可能多地记录 核心转化操作。建议的转化操作的完整列表为 请参阅 Tech API 指南部分。
一般来说,建议捕获以下内容:
- 任何与价值直接相关的成功事件
- 对核心转化有贡献的成功事件,例如 add_to_cart 和 sign_up。
- 深度互动和用户互动,有助于广告客户了解他们与最终用户的互动情况
次要转化操作仅用于观察和报告, 影响出价。详细了解主要和次要转化操作。
用户体验指南
为了最大限度地降低出错风险,建议您 直接进行程序化跟踪,而无需商家输入, 让您的商家知道转化跟踪已设置完毕。
当商家关联现有 Google Ads 账号时,我们建议显示 通知,他们的账号可能已启用了转化跟踪 因为可能存在必须解决的冲突。相关示例如下所示。
技术指南
转化跟踪的工作原理如下。本部分将详细介绍 步骤:
您可以在商家的 Google Ads 账号中创建 'ConversionAction', 跟踪其网站上的购买行为(以及可选的其他客户操作)。
您将该转化操作的代码或代码段添加到 。如需了解详情,请参阅为网站设置转化跟踪。
当客户点击该广告时,系统会在该网站上放置一个临时 Cookie 用户的计算机或移动设备。
当客户完成为广告主定义的操作后,Google 识别 Cookie(通过添加的代码段),并记录 以及“value”等其他参数(如果适用)。
前提条件
在开始之前,请确保您拥有 Google 代码开发者 ID。如果您 拥有 Google 代码开发者 ID,请填写 Google 代码开发者 ID 申请表单。您的开发者 ID 不同 从其他 ID(例如衡量 ID 或转化 ID)进行复制, 用户向其网站衡量代码中添加的任何参数。
创建和配置转化操作
以下示例展示了如何创建转化操作并将其添加到 Google Ads 账号。每个示例都会为以下对象处理所有后台身份验证任务: ,并引导您创建转化操作:
Java
// Copyright 2018 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. package com.google.ads.googleads.examples.remarketing; import static com.google.ads.googleads.examples.utils.CodeSampleHelper.getPrintableDateTime; import com.beust.jcommander.Parameter; import com.google.ads.googleads.examples.utils.ArgumentNames; import com.google.ads.googleads.examples.utils.CodeSampleParams; import com.google.ads.googleads.lib.GoogleAdsClient; import com.google.ads.googleads.v17.enums.ConversionActionCategoryEnum.ConversionActionCategory; import com.google.ads.googleads.v17.enums.ConversionActionStatusEnum.ConversionActionStatus; import com.google.ads.googleads.v17.enums.ConversionActionTypeEnum.ConversionActionType; import com.google.ads.googleads.v17.errors.GoogleAdsError; import com.google.ads.googleads.v17.errors.GoogleAdsException; import com.google.ads.googleads.v17.resources.ConversionAction; import com.google.ads.googleads.v17.resources.ConversionAction.ValueSettings; import com.google.ads.googleads.v17.services.ConversionActionOperation; import com.google.ads.googleads.v17.services.ConversionActionServiceClient; import com.google.ads.googleads.v17.services.MutateConversionActionResult; import com.google.ads.googleads.v17.services.MutateConversionActionsResponse; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Collections; /** Adds a conversion action. */ public class AddConversionAction { private static class AddConversionActionParams extends CodeSampleParams { @Parameter(names = ArgumentNames.CUSTOMER_ID, required = true) private Long customerId; } public static void main(String[] args) { AddConversionActionParams params = new AddConversionActionParams(); if (!params.parseArguments(args)) { // Either pass the required parameters for this example on the command line, or insert them // into the code here. See the parameter class definition above for descriptions. params.customerId = Long.parseLong("INSERT_CUSTOMER_ID_HERE"); } GoogleAdsClient googleAdsClient = null; try { googleAdsClient = GoogleAdsClient.newBuilder().fromPropertiesFile().build(); } catch (FileNotFoundException fnfe) { System.err.printf( "Failed to load GoogleAdsClient configuration from file. Exception: %s%n", fnfe); System.exit(1); } catch (IOException ioe) { System.err.printf("Failed to create GoogleAdsClient. Exception: %s%n", ioe); System.exit(1); } try { new AddConversionAction().runExample(googleAdsClient, params.customerId); } catch (GoogleAdsException gae) { // GoogleAdsException is the base class for most exceptions thrown by an API request. // Instances of this exception have a message and a GoogleAdsFailure that contains a // collection of GoogleAdsErrors that indicate the underlying causes of the // GoogleAdsException. System.err.printf( "Request ID %s failed due to GoogleAdsException. Underlying errors:%n", gae.getRequestId()); int i = 0; for (GoogleAdsError googleAdsError : gae.getGoogleAdsFailure().getErrorsList()) { System.err.printf(" Error %d: %s%n", i++, googleAdsError); } System.exit(1); } } /** * Runs the example. * * @param googleAdsClient the Google Ads API client. * @param customerId the client customer ID. * @throws GoogleAdsException if an API request failed with one or more service errors. */ 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#
// 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 // // http://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. using CommandLine; using Google.Ads.Gax.Examples; using Google.Ads.GoogleAds.Lib; using Google.Ads.GoogleAds.V17.Errors; using Google.Ads.GoogleAds.V17.Resources; using Google.Ads.GoogleAds.V17.Services; using System; using static Google.Ads.GoogleAds.V17.Enums.ConversionActionCategoryEnum.Types; using static Google.Ads.GoogleAds.V17.Enums.ConversionActionStatusEnum.Types; using static Google.Ads.GoogleAds.V17.Enums.ConversionActionTypeEnum.Types; namespace Google.Ads.GoogleAds.Examples.V17 { /// <summary> /// This code example illustrates adding a conversion action. /// </summary> public class AddConversionAction : ExampleBase { /// <summary> /// Command line options for running the <see cref="AddConversionAction"/> example. /// </summary> public class Options : OptionsBase { /// <summary> /// The Google Ads customer ID for which the conversion action is added. /// </summary> [Option("customerId", Required = true, HelpText = "The Google Ads customer ID for which the conversion action is added.")] public long CustomerId { get; set; } } /// <summary> /// Main method, to run this code example as a standalone application. /// </summary> /// <param name="args">The command line arguments.</param> public static void Main(string[] args) { Options options = ExampleUtilities.ParseCommandLine<Options>(args); AddConversionAction codeExample = new AddConversionAction(); Console.WriteLine(codeExample.Description); codeExample.Run(new GoogleAdsClient(), options.CustomerId); } /// <summary> /// Returns a description about the code example. /// </summary> public override string Description => "This code example illustrates adding a conversion action."; /// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the conversion action is /// added.</param> 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
<?php /** * Copyright 2018 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. */ namespace Google\Ads\GoogleAds\Examples\Remarketing; require __DIR__ . '/../../vendor/autoload.php'; use GetOpt\GetOpt; use Google\Ads\GoogleAds\Examples\Utils\ArgumentNames; use Google\Ads\GoogleAds\Examples\Utils\ArgumentParser; use Google\Ads\GoogleAds\Examples\Utils\Helper; use Google\Ads\GoogleAds\Lib\V17\GoogleAdsClient; use Google\Ads\GoogleAds\Lib\V17\GoogleAdsClientBuilder; use Google\Ads\GoogleAds\Lib\V17\GoogleAdsException; use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder; use Google\Ads\GoogleAds\V17\Enums\ConversionActionCategoryEnum\ConversionActionCategory; use Google\Ads\GoogleAds\V17\Enums\ConversionActionStatusEnum\ConversionActionStatus; use Google\Ads\GoogleAds\V17\Enums\ConversionActionTypeEnum\ConversionActionType; use Google\Ads\GoogleAds\V17\Errors\GoogleAdsError; use Google\Ads\GoogleAds\V17\Resources\ConversionAction; use Google\Ads\GoogleAds\V17\Resources\ConversionAction\ValueSettings; use Google\Ads\GoogleAds\V17\Services\ConversionActionOperation; use Google\Ads\GoogleAds\V17\Services\MutateConversionActionsRequest; use Google\ApiCore\ApiException; /** This example illustrates adding a conversion action. */ class AddConversionAction { private const CUSTOMER_ID = 'INSERT_CUSTOMER_ID_HERE'; public static function main() { // Either pass the required parameters for this example on the command line, or insert them // into the constants above. $options = (new ArgumentParser())->parseCommandArguments([ ArgumentNames::CUSTOMER_ID => GetOpt::REQUIRED_ARGUMENT ]); // Generate a refreshable OAuth2 credential for authentication. $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build(); // Construct a Google Ads client configured from a properties file and the // OAuth2 credentials above. $googleAdsClient = (new GoogleAdsClientBuilder()) ->fromFile() ->withOAuth2Credential($oAuth2Credential) // We set this value to true to show how to use GAPIC v2 source code. You can remove the // below line if you wish to use the old-style source code. Note that in that case, you // probably need to modify some parts of the code below to make it work. // For more information, see // https://developers.devsite.corp.google.com/google-ads/api/docs/client-libs/php/gapic. ->usingGapicV2Source(true) ->build(); try { self::runExample( $googleAdsClient, $options[ArgumentNames::CUSTOMER_ID] ?: self::CUSTOMER_ID ); } catch (GoogleAdsException $googleAdsException) { printf( "Request with ID '%s' has failed.%sGoogle Ads failure details:%s", $googleAdsException->getRequestId(), PHP_EOL, PHP_EOL ); foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as $error) { /** @var GoogleAdsError $error */ printf( "\t%s: %s%s", $error->getErrorCode()->getErrorCode(), $error->getMessage(), PHP_EOL ); } exit(1); } catch (ApiException $apiException) { printf( "ApiException was thrown with message '%s'.%s", $apiException->getMessage(), PHP_EOL ); exit(1); } } /** * Runs the example. * * @param GoogleAdsClient $googleAdsClient the Google Ads API client * @param int $customerId the customer ID */ 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 ); } } } AddConversionAction::main();
Python
#!/usr/bin/env python # Copyright 2018 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. """This example illustrates adding a conversion action.""" import argparse import sys import uuid from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.errors import GoogleAdsException 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}".' ) if __name__ == "__main__": parser = argparse.ArgumentParser( description="Adds a conversion action 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() # 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") 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)
Ruby
#!/usr/bin/env ruby # Encoding: utf-8 # # Copyright 2018 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. # # This code example illustrates adding a conversion action. require 'optparse' require 'google/ads/google_ads' require 'date' 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 if __FILE__ == $0 options = {} # The following parameter(s) should be provided to run the example. You can # either specify these by changing the INSERT_XXX_ID_HERE values below, or on # the command line. # # Parameters passed on the command line will override any parameters set in # code. # # Running the example with -h will print the command line usage. options[:customer_id] = 'INSERT_CUSTOMER_ID_HERE' OptionParser.new do |opts| opts.banner = sprintf('Usage: %s [options]', File.basename(__FILE__)) opts.separator '' opts.separator 'Options:' opts.on('-C', '--customer-id CUSTOMER-ID', String, 'Customer ID') do |v| options[:customer_id] = v end opts.separator '' opts.separator 'Help:' opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end end.parse! begin add_conversion_action(options.fetch(:customer_id).tr("-", "")) rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e e.failure.errors.each do |error| STDERR.printf("Error with message: %s\n", error.message) if error.location error.location.field_path_elements.each do |field_path_element| STDERR.printf("\tOn field: %s\n", field_path_element.field_name) end end error.error_code.to_h.each do |k, v| next if v == :UNSPECIFIED STDERR.printf("\tType: %s\n\tCode: %s\n", k, v) end end raise end end
Perl
#!/usr/bin/perl -w # # 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 # # http://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. # # This example illustrates adding a conversion action. use strict; use warnings; use utf8; use FindBin qw($Bin); use lib "$Bin/../../lib"; use Google::Ads::GoogleAds::Client; use Google::Ads::GoogleAds::Utils::GoogleAdsHelper; use Google::Ads::GoogleAds::V17::Resources::ConversionAction; use Google::Ads::GoogleAds::V17::Resources::ValueSettings; use Google::Ads::GoogleAds::V17::Enums::ConversionActionCategoryEnum qw(DEFAULT); use Google::Ads::GoogleAds::V17::Enums::ConversionActionTypeEnum qw(WEBPAGE); use Google::Ads::GoogleAds::V17::Enums::ConversionActionStatusEnum qw(ENABLED); use Google::Ads::GoogleAds::V17::Services::ConversionActionService::ConversionActionOperation; use Getopt::Long qw(:config auto_help); use Pod::Usage; use Cwd qw(abs_path); use Data::Uniqid qw(uniqid); # The following parameter(s) should be provided to run the example. You can # either specify these by changing the INSERT_XXX_ID_HERE values below, or on # the command line. # # Parameters passed on the command line will override any parameters set in # code. # # Running the example with -h will print the command line usage. my $customer_id = "INSERT_CUSTOMER_ID_HERE"; 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; } # Don't run the example if the file is being included. if (abs_path($0) ne abs_path(__FILE__)) { return 1; } # Get Google Ads Client, credentials will be read from ~/googleads.properties. my $api_client = Google::Ads::GoogleAds::Client->new(); # By default examples are set to die on any server returned fault. $api_client->set_die_on_faults(1); # Parameters passed on the command line will override any parameters set in code. GetOptions("customer_id=s" => \$customer_id); # Print the help message if the parameters are not initialized in the code nor # in the command line. pod2usage(2) if not check_params($customer_id); # Call the example. add_conversion_action($api_client, $customer_id =~ s/-//gr); =pod =head1 NAME add_conversion_action =head1 DESCRIPTION This example illustrates adding a conversion action. =head1 SYNOPSIS add_conversion_action.pl [options] -help Show the help message. -customer_id The Google Ads customer ID. =cut
由于上述示例在本质上都是通用的,因此下面是一些额外的说明, 已针对效果最大化广告系列正确配置 ConversionAction。 您应按如下方式配置每项转化操作:
类型 - 将 ConversionActionType 设置为“网页”,因为这些购买操作 事件发生在网站上。
可出价 - 为您的主要渠道设为
true
转化操作(购买) 以提高销售额为目标进行优化 对于次要转化操作(例如添加到购物车), 将值设置为false
。类别 - 针对每种转化操作(主要或 次要),请设置 ConversionActionCategory。 您可以在下方找到相关对话操作类别 。 请注意,Google Ads 会自动分配转化 转化操作和标准转化目标。 例如,系统会为购买转化操作分配 添加到名为“购买”的标准转化目标 之后,您可以配置效果最大化广告系列 广告系列,使其针对这一“购买”目标进行优化。
您可以在下方找到建议的转化操作列表。我们建议 至少实施前四项转化操作,并尽可能多地 建议采取的其他行动。
您也可以考虑 与线上销售相关的其他活动。如需更精细的 也可以创建其他转化操作或自定义 转化操作(例如“添加付款信息”的操作) 每当用户在网站上使用搜索选项时触发 "搜索"每次用户在网站上使用搜索选项时触发)。次要 转化操作可为您的商家提供额外的跟踪, 用于观察目的。
优先级 | 转化操作 | 转化操作类别 | Google 代码事件名称 | 说明 |
---|---|---|---|---|
强制 | 购买 | 购买 | purchase | 用户完成购买 |
强烈建议所有商店开设平台参与 | 添加到购物车 | ADD_TO_CART | add_to_cart | 用户将产品添加到购物车 |
强烈建议所有商店开设平台参与 | 开始结账 | BEGIN_CHECKOUT | begin_checkout | 用户开始结账流程 |
强烈建议所有商店开设平台参与 | 查看商品 | PAGE_VIEW | page_view | 用户打开商品页面 |
如果适用,强烈建议提供(通常不适用于商店开设平台) | 注册 | 注册 | sign_up | 用户注册账号 |
如果适用,强烈建议提供(通常不适用于商店开设平台) | 产生潜在客户 | SUBMIT_LEAD_FORM | generate_lead | 用户通过表单生成潜在客户 |
如果适用,强烈建议提供(通常不适用于商店开设平台) | 订阅 | SUBSCRIBE_PAID | 不适用(自定义) | 用户订阅了付费服务 |
如果适用,强烈建议提供(通常不适用于商店开设平台) | 预约服务 | BOOK_APPOINTMENT | 不适用(自定义) | 用户进行预约 |
如果适用,强烈建议提供(通常不适用于商店开设平台) | 咨询报价 | REQUEST_QUOTE | 不适用(自定义) | 用户提交估算价格的表单 |
已有 Google Ads 账号的商家
如果您允许商家使用现有 Google Ads 账号进行初始配置,您可以运行 账号已有转化操作的情况。我们不 建议您使用现有转化操作 已正确设置此外,您还需要执行一些额外步骤 以处理这些潜在的情况:
账号有多个目标(例如购买 + 网页浏览 + 联系人) 全部标记为“账号默认”新广告系列制作完成后, 默认情况下,系统会针对所有这些目标进行优化。对于 效果最大化广告系列。
账号已有一项(或多项)转化操作来跟踪购买和 就已归入“购买”目标之下也就是说, 广告系列重复统计一次购买,因为触发了两个转化跟踪代码。
为了确保效果最大化广告系列使用您的自定义转化操作 并且只能执行以下操作:
创建 CustomConversionGoal 并添加“购买”转化操作 添加到目标的
conversion_actions[]
列表中。将状态设置为已启用。在效果最大化广告系列的 ConversionGoalCampaignConfig 中,设置 将
custom_conversion_goal
设置为您在第 (1) 步中创建的自定义目标。执行完第 (2) 步操作后,Google Ads 应该已经自动更新 广告系列的 ConversionGoalCampaignConfig,以便设置
goal_config_level
到 CAMPAIGN(而不是 CUSTOMER,这样它会引导其使用 账号默认目标),但有必要仔细检查一下, 情况。
检索转化操作的代码
创建转化操作后,您需要将 相应代码段(称为 代码)添加到 广告客户的网站为确保 Google Ads 可以衡量所有转化 无论客户使用何种浏览器,请使用 更新后的 Google Ads 转化跟踪代码。该代码由两部分组成 部分:
global_site_tag
:必须安装在 广告客户的网站event_snippet
:应放置在指明网页上 转化操作,例如结账确认页或潜在客户提交页。
您可以使用 ConversionActionService 获取这两部分。
该代码会设置 Cookie,以存储客户或广告的唯一标识符 点击。Cookie 收到广告点击 来自 Google 点击标识符 (GCLID) 参数的信息 。您必须启用广告客户的网站 潜在客户跟踪系统来捕获和存储 GCLID,这是 对于 Google 广告的每次展示,Google Ads 都会提供相应支持。
详细了解全局代码及其添加位置
Google 代码 (gtag.js) 是一种代码植入框架兼 API,可让您通过
将事件数据同时发送给 Google Ads 和 Google Analytics。全局网站代码
可与事件代码段或电话号码代码段配合使用,
转化次数。向每个网页的 <head>
部分添加 Google 代码
,并将其配置为与 Google Ads 配合使用。然后,您可以
使用 gtag() 命令捕获事件并将数据发送给 Google Ads。
要了解其工作原理,请参阅
使用全局网站代码进行 Google Ads 转化跟踪。
您可以将以下命令与 Google 代码搭配使用:
config: 初始化 Google 产品(Google Ads、Google Analytics 等)、 配置设置,并准备将数据发送到账号。
事件:通过发送如下事件来注册转化: 购买(推荐)或添加到购物车 (次要转化操作)。 建议您查看 gtag.js 事件参考指南。
set:设置网页上所有事件通用的参数,例如币种。
以下示例是全局网站代码的 JavaScript 代码段, 向 Google Ads 发送数据的方法。GOOGLE_CONVERSION_ID 占位符值是 一个广告客户账号的唯一数字 ID。
<!-- Google Tag (gtag.js) - Google Ads: GOOGLE_CONVERSION_ID -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-GOOGLE_CONVERSION_ID">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('set', 'developer_id.<developer ID>', true); // Replace with your Google tag Developer ID
gtag('config', 'AW-GOOGLE_CONVERSION_ID');
</script>
Google 代码段在每个网页上应仅显示一次。如果存在 gtag.js 实例,则应将新的代码 ID 添加到现有代码中。发送 则可以向“config”针对每个 指定每个账号的转化 ID,如下所示: 如下例中所示:
<!-- Google Tag (gtag.js) - Google Ads: GOOGLE_CONVERSION_ID_1 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-GOOGLE_CONVERSION_ID_1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', 'AW-GOOGLE_CONVERSION_ID_1');
gtag('config', 'AW-GOOGLE_CONVERSION_ID_2');
</script>
详细了解事件代码段及其添加位置
为使购买转化跟踪正常工作,购买事件代码段 。这通常是 确认页面。您可以将事件代码段放置在源代码中全局代码之后的任何位置 代码段。次要转化操作的事件代码段 (例如:添加到购物车)。
在下面的示例代码段中,AW-CONVERSION_ID 和 gTag_developer_ID 代表您的 Google Ads 账号和 Google 代码开发者账号,AW-CONVERSION_LABEL 代表转化 标签,每个转化操作的 ID 都是唯一的:
<!-- Event snippet for a purchase conversion page -->
<script>
gtag('event', 'conversion', {
'send_to':'AW-CONVERSION_ID/CONVERSION_LABEL',
'developer_id.<gTag developer ID>': true,
'transaction_id': '<transaction_id (string)>' //unique ID for the transaction (e.g. an order ID); it's used for de-duplication purposes
'value': 1.0,
'currency': 'USD', //three-letter currency code, useful for advertisers who accept multiple currencies
'country': 'US',
'new_customer': false, //new customer acquisition goal
'tax': 1.24, //tax cost-US only
'shipping': 0.00, //shipping cost-US only
'delivery_postal_code': '94043', //shipping data validation-US only
'estimated_delivery_date': '2020-07-31', //shipping validation-US only
'aw_merchant_id': 12345, //shipping validation-US only
'aw_feed_country': 'US', //shipping validation-US only
'aw_feed_language': 'EN', //shipping validation-US only
'items': [
{
'id': 'P12345',
'name': 'Android Warhol T-Shirt',
'quantity': 2,
'price': 12.04,
'estimated_delivery_date': '2020-07-31', //shipping-US only
'google_business_vertical': 'retail'
}, …],
});
</script>
虽然有些参数是可选的,但建议您尽可能多地添加 所有可用信息详细了解哪些参数 每种活动类型都有各自的可用选项。
参数可以提供有关用户互动方式的更多信息 互动情况
如果您想衡量基于点击的转化事件 (例如,使用 AJAX 的网站的按钮或动态响应), 您也可以改用以下代码段:
<!-- Event snippet for test conversion click -->
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. -->
<script>
function gtag_report_conversion(url) {
var callback = function () {
if (typeof(url) != 'undefined') {
window.location = url;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-CONVERSION_ID/CONVERSION_LABEL',
'value': 1.0,
'event_callback': callback,
//other parameters
});
return false;
}
</script>
实现 Consent API(也称为意见征求模式)
Google 代码内置了 Consent API 来管理用户意见征求模式。它能够 区分用户对于广告用途 Cookie 与分析 Cookie 的同意情况 目的。
预期结果是客户至少获得 gtag('consent', 'update' {...} 通话已整合,客户无需执行任何操作。这应该 确保 Google 代码(Google Ads、Floodlight、Google Analytics、转化链接器) 能够读取最新的用户同意情况,并将其包含在广告网络中 (通过参数 &gcs)。
其他实施步骤包括部署或帮助广告主 部署(例如通过界面)gtag('consent', default' {...}) 状态以及 取消屏蔽 Google 代码(例如:不根据用户同意情况触发) 启用意见征求模式,以知晓用户意见的方式触发它们。
如需了解实现方面的详细信息,请参阅管理用户意见征求设置(网站)。
提示
在 Google Ads 经理账号中,您可以跟踪所有 广告客户账号。请参阅 跨账号转化跟踪简介。
测试转化跟踪实施情况是否 前往某个商家的 网站(或内部测试网站) 并做出真正的购买 然后,您可以在 Google Tag Assistant 工具中进行观察, 参阅此问题排查指南 验证 Google Ads 是否已看到您的代码 并且已成功记录转化。 如需排查其他问题,请访问网站级代码植入问题排查。
您可以使用增强型转化作为对前面的转化跟踪代码的补充, 从而提高转化衡量的准确性 并解锁更强大的出价功能。 不妨详细了解如何设置增强型转化。 在实现增强型转化之前, 您应确保自己的商家能够遵守 Google Ads 中的增强型转化客户数据政策。