4.1.5 Theo dõi lượt chuyển đổi
Giá trị và tác động đối với hoạt động kinh doanh
Để cung cấp hiệu quả công nghệ học máy và thông tin phân tích mạnh mẽ của hệ sinh thái Google cho các chiến dịch quảng cáo của khách hàng là người bán, bạn cần đặt thẻ theo dõi lượt chuyển đổi và thẻ tái tiếp thị trên trang web của khách hàng.
Lượt chuyển đổi trong Google Ads là khi người dùng thực hiện một hành động cụ thể nào đó sau khi nhấp vào một quảng cáo, chẳng hạn như mua sản phẩm, cài đặt ứng dụng di động hoặc đăng ký tham gia danh sách email. Tính năng theo dõi lượt chuyển đổi cung cấp thông tin chi tiết quan trọng về hành động của người dùng sau khi xem hoặc nhấp vào quảng cáo, bao gồm cả thông tin để tính toán và so sánh lợi tức đầu tư (ROI) nhằm giúp khách hàng của bạn đưa ra quyết định về nơi tập trung chi tiêu quảng cáo. Việc theo dõi cũng giúp đảm bảo rằng dữ liệu có sẵn cho mục đích đối chiếu. Đơn đặt hàng sẽ khác nhau tuỳ thuộc vào sản phẩm hoặc danh mục, vì vậy, tính năng theo dõi lượt chuyển đổi cũng có thể hữu ích để cho biết cách các nhóm trang thông tin cụ thể đang chuyển đổi thành lượt bán hàng.
Mục tiêu lượt chuyển đổi là một nhóm hành động chuyển đổi có cùng mục tiêu cơ bản. Ví dụ: "Giao dịch mua" có thể là một mục tiêu lượt chuyển đổi có "Giao dịch mua trên trang web" và "Lượt bán hàng tại cửa hàng thực tế" làm hành động chuyển đổi.
Hệ thống vẫn dùng hành động chuyển đổi để theo dõi lượt chuyển đổi và tối ưu hoá chiến dịch. Bạn tạo hành động chuyển đổi và Google sẽ nhóm các hành động đó trong mục tiêu chuyển đổi.
Hành động chuyển đổi giao dịch mua
Việc triển khai tính năng theo dõi lượt chuyển đổi được mô tả ở đây sẽ giúp tài khoản Google Ads của người bán đo lường số lượt chuyển đổi Mua hàng và giá trị của những lượt chuyển đổi này. Nếu không có tính năng theo dõi lượt chuyển đổi, bạn sẽ không thể đo lường giá trị kinh doanh mà chiến dịch mang lại về ROAS (lợi tức trên chi tiêu quảng cáo). Tính năng này cũng gửi thêm các tín hiệu dữ liệu giúp chiến dịch tối ưu hoá hiệu suất.
Các hành động chuyển đổi khác
Mặc dù bạn chỉ cần hành động chuyển đổi giao dịch mua, nhưng việc theo dõi các hành động chuyển đổi khác có thể cung cấp thêm thông tin chi tiết cho người bán. Bạn nên ghi lại mọi thứ có thể, đồng thời triển khai nhiều hành động chuyển đổi chính nhất có thể. Danh sách đầy đủ các hành động chuyển đổi được đề xuất có trong phần hướng dẫn về Tech API.
Nói chung, bạn nên chụp những ảnh sau:
- Mọi sự kiện thành công được liên kết trực tiếp với giá trị
- Các sự kiện thành công đóng góp vào lượt chuyển đổi chính, chẳng hạn như add_to_cart và sign_up.
- Lượt tương tác và lượt tương tác của người dùng giúp nhà quảng cáo hiểu được cách họ tương tác với người dùng cuối
Các hành động chuyển đổi phụ chỉ dùng để quan sát và báo cáo, không ảnh hưởng đến hoạt động đặt giá thầu.Tìm hiểu thêm về hành động chuyển đổi chính và phụ.
Hướng dẫn về trải nghiệm người dùng
Để giảm thiểu nguy cơ xảy ra lỗi, bạn nên triển khai tính năng theo dõi lượt chuyển đổi theo phương thức lập trình mà không cần nhà bán hàng nhập dữ liệu, nhưng bạn phải đảm bảo rằng nhà bán hàng biết rằng bạn đã thiết lập tính năng theo dõi lượt chuyển đổi.
Khi người bán liên kết một tài khoản Google Ads hiện có, bạn nên hiển thị một thông báo rằng tài khoản của họ có thể đã thiết lập tính năng theo dõi lượt chuyển đổi, vì có thể xảy ra xung đột mà họ phải giải quyết. Sau đây là ví dụ minh hoạ.

Hướng dẫn về công nghệ
Sau đây là cách hoạt động của tính năng theo dõi lượt chuyển đổi. Phần này trình bày chi tiết hơn về từng bước:
Bạn tạo một "ConversionAction" trong tài khoản Google Ads của người bán để theo dõi các giao dịch mua (và các hành động khác của khách hàng nếu muốn) được thực hiện trên trang web của họ.
Bạn thêm thẻ hoặc đoạn mã cho hành động chuyển đổi đó vào một trang web hoặc ứng dụng di động. Để biết thông tin chi tiết, hãy xem bài viết Thiết lập tính năng theo dõi lượt chuyển đổi cho trang web.
Khi một khách hàng nhấp vào quảng cáo, một cookie tạm thời sẽ được đặt trên máy tính hoặc thiết bị di động của khách hàng.
Khi khách hàng hoàn tất hành động được xác định cho nhà quảng cáo, Google sẽ nhận dạng cookie (thông qua đoạn mã đã thêm) và ghi lại một lượt chuyển đổi cùng với các thông số khác, chẳng hạn như "giá trị" nếu thích hợp.
Điều kiện tiên quyết
Trước khi bắt đầu, hãy đảm bảo bạn có Mã nhận dạng nhà phát triển thẻ Google. Nếu bạn không có Mã nhận dạng nhà phát triển thẻ Google, hãy điền vào biểu mẫu yêu cầu Mã nhận dạng nhà phát triển thẻ Google. Mã nhận dạng nhà phát triển của bạn khác với các mã nhận dạng khác, chẳng hạn như Mã đo lường hoặc Mã nhận dạng lượt chuyển đổi mà người dùng cuối thêm vào mã đo lường trang web của họ.
Tạo và thiết lập hành động chuyển đổi
Các ví dụ sau đây cho biết cách tạo một hành động chuyển đổi và thêm hành động đó vào tài khoản Google Ads. Mỗi mẫu sẽ xử lý tất cả các tác vụ xác thực trong nền cho bạn và hướng dẫn bạn tạo một hành động chuyển đổi:
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.v23.enums.ConversionActionCategoryEnum.ConversionActionCategory; import com.google.ads.googleads.v23.enums.ConversionActionStatusEnum.ConversionActionStatus; import com.google.ads.googleads.v23.enums.ConversionActionTypeEnum.ConversionActionType; import com.google.ads.googleads.v23.errors.GoogleAdsError; import com.google.ads.googleads.v23.errors.GoogleAdsException; import com.google.ads.googleads.v23.resources.ConversionAction; import com.google.ads.googleads.v23.resources.ConversionAction.ValueSettings; import com.google.ads.googleads.v23.services.ConversionActionOperation; import com.google.ads.googleads.v23.services.ConversionActionServiceClient; import com.google.ads.googleads.v23.services.MutateConversionActionResult; import com.google.ads.googleads.v23.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.V23.Errors; using Google.Ads.GoogleAds.V23.Resources; using Google.Ads.GoogleAds.V23.Services; using System; using static Google.Ads.GoogleAds.V23.Enums.ConversionActionCategoryEnum.Types; using static Google.Ads.GoogleAds.V23.Enums.ConversionActionStatusEnum.Types; using static Google.Ads.GoogleAds.V23.Enums.ConversionActionTypeEnum.Types; namespace Google.Ads.GoogleAds.Examples.V23 { /// <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.V23.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\V23\GoogleAdsClient; use Google\Ads\GoogleAds\Lib\V23\GoogleAdsClientBuilder; use Google\Ads\GoogleAds\Lib\V23\GoogleAdsException; use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder; use Google\Ads\GoogleAds\V23\Enums\ConversionActionCategoryEnum\ConversionActionCategory; use Google\Ads\GoogleAds\V23\Enums\ConversionActionStatusEnum\ConversionActionStatus; use Google\Ads\GoogleAds\V23\Enums\ConversionActionTypeEnum\ConversionActionType; use Google\Ads\GoogleAds\V23\Errors\GoogleAdsError; use Google\Ads\GoogleAds\V23\Resources\ConversionAction; use Google\Ads\GoogleAds\V23\Resources\ConversionAction\ValueSettings; use Google\Ads\GoogleAds\V23\Services\ConversionActionOperation; use Google\Ads\GoogleAds\V23\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) ->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 from google.ads.googleads.v23.resources.types.conversion_action import ( ConversionAction, ) from google.ads.googleads.v23.services.services.conversion_action_service import ( ConversionActionServiceClient, ) from google.ads.googleads.v23.services.types.conversion_action_service import ( ConversionActionOperation, MutateConversionActionsResponse, ) def main(client: GoogleAdsClient, customer_id: str) -> None: conversion_action_service: ConversionActionServiceClient = ( client.get_service("ConversionActionService") ) # Create the operation. conversion_action_operation: ConversionActionOperation = client.get_type( "ConversionActionOperation" ) # Create conversion action. conversion_action: ConversionAction = 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: ConversionAction.ValueSettings = ( conversion_action.value_settings ) value_settings.default_value = 15.0 value_settings.always_use_default_value = True # Add the conversion action. conversion_action_response: MutateConversionActionsResponse = ( 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 = 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: argparse.Namespace = parser.parse_args() # GoogleAdsClient will read the google-ads.yaml configuration file in the # home directory if none is specified. googleads_client: GoogleAdsClient = GoogleAdsClient.load_from_storage( version="v23" ) 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' require_relative '../shared/error_handler.rb' 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 GoogleAdsErrorHandler.handle_google_ads_error(e) raise # Re-raise the error to maintain original script behavior. 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::V23::Resources::ConversionAction; use Google::Ads::GoogleAds::V23::Resources::ValueSettings; use Google::Ads::GoogleAds::V23::Enums::ConversionActionCategoryEnum qw(DEFAULT); use Google::Ads::GoogleAds::V23::Enums::ConversionActionTypeEnum qw(WEBPAGE); use Google::Ads::GoogleAds::V23::Enums::ConversionActionStatusEnum qw(ENABLED); use Google::Ads::GoogleAds::V23::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::V23::Resources::ConversionAction->new({ name => $conversion_action_name, category => DEFAULT, type => WEBPAGE, status => ENABLED, viewThroughLookbackWindowDays => 15, valueSettings => Google::Ads::GoogleAds::V23::Resources::ValueSettings->new({ defaultValue => 23.41, alwaysUseDefaultValue => "true" })}); # Create a conversion action operation. my $conversion_action_operation = Google::Ads::GoogleAds::V23::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
curl
Vì các ví dụ trước đó mang tính chung chung, nên sau đây là những lưu ý bổ sung để ConversionAction được định cấu hình chính xác cho chiến dịch Tối đa hoá hiệu suất. Mỗi hành động chuyển đổi của bạn phải được định cấu hình như sau:
Loại – Đặt ConversionActionType thành WEBPAGE, vì những sự kiện mua hàng này đang diễn ra trên một trang web.
Có thể đặt giá thầu – Đặt thành
truecho hành động chuyển đổi chính (mua hàng) để tối ưu hoá chiến dịch hướng đến lượt bán hàng. Đối với hành động chuyển đổi phụ (ví dụ: thêm vào giỏ hàng), hãy đặt giá trị thànhfalse.Danh mục – Đối với mỗi hành động chuyển đổi (chính hoặc phụ),hãy đặt ConversionActionCategory. Dưới đây, bạn có thể tìm thấy danh mục hành động chuyển đổi có liên quan cho từng hành động trong số 7 hành động chuyển đổi mà chúng tôi đề xuất bạn triển khai. Lưu ý: Google Ads tự động chỉ định hành động chuyển đổi cho một mục tiêu lượt chuyển đổi chuẩn dựa trên danh mục của hành động đó. Ví dụ: hành động chuyển đổi lượt mua hàng được chỉ định cho mục tiêu lượt chuyển đổi chuẩn có tên là "Lượt mua hàng". Sau đó, bạn có thể định cấu hình chiến dịch Tối đa hoá hiệu suất để tối ưu hoá cho mục tiêu này là Lượt mua hàng.
Bạn có thể xem danh sách các hành động chuyển đổi được đề xuất bên dưới. Bạn nên triển khai ít nhất 4 hành động chuyển đổi đầu tiên và nhiều hành động được đề xuất khác nhất có thể.
Bạn cũng có thể cân nhắc việc triển khai các sự kiện bổ sung có liên quan đến doanh số bán hàng trực tuyến. Để theo dõi chi tiết hơn nữa, bạn cũng có thể tạo thêm hành động chuyển đổi hoặc hành động chuyển đổi tuỳ chỉnh (ví dụ: hành động "thêm thông tin thanh toán" mỗi khi người dùng sử dụng lựa chọn tìm kiếm trên trang web hoặc hành động "tìm kiếm" mỗi khi người dùng sử dụng lựa chọn tìm kiếm trên trang web). Hành động chuyển đổi phụ cung cấp thông tin theo dõi bổ sung cho người bán và được Google Ads sử dụng để quan sát.
| Mức độ ưu tiên | Hành động chuyển đổi | Danh mục hành động chuyển đổi | Tên sự kiện của thẻ Google | Mô tả |
|---|---|---|---|---|
| Bắt buộc | Lượt mua hàng | MUA | purchase | Người dùng hoàn tất giao dịch mua |
| Rất nên dùng cho tất cả nhà tạo cửa hàng | Thêm vào giỏ hàng | ADD_TO_CART | add_to_cart | Người dùng thêm một sản phẩm vào giỏ hàng |
| Rất nên dùng cho tất cả nhà tạo cửa hàng | Bắt đầu quy trình thanh toán | BEGIN_CHECKOUT | begin_checkout | Người dùng bắt đầu quy trình thanh toán |
| Rất nên dùng cho tất cả nhà tạo cửa hàng | Xem mục | PAGE_VIEW | page_view | Người dùng mở một trang sản phẩm |
| Nên có khi thích hợp (thường không áp dụng cho trình tạo cửa hàng) | Đăng ký | ĐĂNG KÝ | sign_up | Người dùng đăng ký tài khoản |
| Nên có khi thích hợp (thường không áp dụng cho trình tạo cửa hàng) | Tạo khách hàng tiềm năng | SUBMIT_LEAD_FORM | generate_lead | Người dùng tạo khách hàng tiềm năng thông qua biểu mẫu |
| Nên có khi thích hợp (thường không áp dụng cho trình tạo cửa hàng) | Đăng ký | SUBSCRIBE_PAID | không áp dụng (tuỳ chỉnh) | Người dùng đăng ký một dịch vụ có tính phí |
| Nên có khi thích hợp (thường không áp dụng cho trình tạo cửa hàng) | Đặt lịch hẹn | BOOK_APPOINTMENT | không áp dụng (tuỳ chỉnh) | Người dùng đặt lịch hẹn |
| Nên có khi thích hợp (thường không áp dụng cho trình tạo cửa hàng) | Lượt yêu cầu thông tin báo giá | REQUEST_QUOTE | không áp dụng (tuỳ chỉnh) | Người dùng gửi một biểu mẫu yêu cầu báo giá ước tính |
Người bán có tài khoản Google Ads hiện có
Nếu cho phép người bán tham gia bằng tài khoản Google Ads hiện có, bạn có thể gặp phải trường hợp tài khoản đã có hành động chuyển đổi. Bạn không nên sử dụng hành động chuyển đổi hiện có vì không có gì đảm bảo rằng hành động đó đã được thiết lập đúng cách. Ngoài ra, bạn phải thực hiện thêm các bước để xử lý những trường hợp có thể xảy ra này:
Tài khoản có nhiều mục tiêu (ví dụ: Lượt mua hàng + Lượt xem trang + Lượt liên hệ) và tất cả đều được đánh dấu là "mục tiêu mặc định trong tài khoản". Khi bạn tạo một chiến dịch mới, chiến dịch đó sẽ mặc định tối ưu hoá cho tất cả các mục tiêu này. Bạn không muốn điều này xảy ra đối với chiến dịch Tối đa hoá hiệu suất.
Tài khoản đã có một (hoặc nhiều) hành động chuyển đổi để theo dõi giao dịch mua và hành động đó đã được nhóm trong mục tiêu Giao dịch mua. Điều này có nghĩa là sau khi bạn tăng gấp đôi số lượt mua hàng của chiến dịch, vì có 2 thẻ chuyển đổi đang kích hoạt.
Để đảm bảo chiến dịch Tối đa hoá hiệu suất sử dụng hành động chuyển đổi tuỳ chỉnh của bạn và chỉ hành động đó:
Tạo một CustomConversionGoal và thêm hành động chuyển đổi Mua hàng vào danh sách
conversion_actions[]của mục tiêu. Đặt trạng thái thành BẬT.Trong ConversionGoalCampaignConfig của chiến dịch Tối đa hoá hiệu suất, hãy đặt
custom_conversion_goalthành mục tiêu tuỳ chỉnh mà bạn đã tạo ở bước (1).Do bước (2), Google Ads sẽ tự động cập nhật ConversionGoalCampaignConfig của chiến dịch sao cho
goal_config_levelđược đặt thành CAMPAIGN (thay vì CUSTOMER, sẽ hướng dẫn chiến dịch sử dụng các mục tiêu mặc định của tài khoản), nhưng bạn nên kiểm tra kỹ để đảm bảo rằng điều này thực sự đã xảy ra.
Truy xuất thẻ cho hành động chuyển đổi
Sau khi tạo hành động chuyển đổi, bạn cần chèn đoạn mã tương ứng (được gọi là thẻ) vào trang chuyển đổi trên trang web của nhà quảng cáo. Để đảm bảo rằng Google Ads có thể đo lường tất cả lượt chuyển đổi bất kể trình duyệt của khách hàng, hãy sử dụng thẻ theo dõi lượt chuyển đổi đã cập nhật của Google Ads. Thẻ này bao gồm hai phần:
global_site_tagphải được cài đặt trên mọi trang trong trang web của nhà quảng cáo.event_snippet, bạn nên đặt thẻ này trên những trang web cho biết một hành động chuyển đổi, chẳng hạn như trang xác nhận thanh toán hoặc trang gửi khách hàng tiềm năng.
Bạn có thể truy xuất hai phần này bằng ConversionActionService.
Thẻ này đặt cookie để lưu trữ một giá trị nhận dạng riêng biệt cho mỗi khách hàng hoặc lượt nhấp vào quảng cáo đã đưa khách hàng đến trang web. Các cookie này nhận thông tin về lượt nhấp vào quảng cáo từ một tham số Giá trị nhận dạng lượt nhấp của Google (GCLID) có trong thẻ theo dõi lượt chuyển đổi. Bạn phải cho phép trang web của nhà quảng cáo và hệ thống theo dõi khách hàng tiềm năng ghi nhận và lưu trữ GCLID. Đây là mã nhận dạng duy nhất mà Google Ads cung cấp cho mỗi lượt hiển thị quảng cáo trên Google.
Tìm hiểu thêm về thẻ toàn cầu và vị trí cài đặt thẻ này
Thẻ Google (gtag.js) là một API và khung gắn thẻ cho phép bạn gửi dữ liệu sự kiện đến cả Google Ads và Google Analytics. Thẻ toàn trang web phối hợp với một đoạn mã sự kiện hoặc đoạn mã điện thoại để theo dõi lượt chuyển đổi của bạn. Thêm thẻ Google vào mục <head> của mỗi trang trên trang web của nhà quảng cáo và định cấu hình thẻ đó để hoạt động với Google Ads. Sau đó, bạn có thể sử dụng các lệnh gtag() để ghi nhận sự kiện và gửi dữ liệu đến Google Ads.
Để hiểu cách hoạt động của tính năng này, hãy xem bài viết Sử dụng thẻ toàn trang web để theo dõi lượt chuyển đổi trên Google Ads.
Bạn có thể dùng các lệnh sau với thẻ Google:
config: Khởi chạy một sản phẩm của Google (Google Ads, Analytics, v.v.), định cấu hình các chế độ cài đặt và chuẩn bị gửi dữ liệu đến một tài khoản.
event: Đăng ký lượt chuyển đổi bằng cách gửi một sự kiện như mua hàng (nên dùng) hoặc thêm vào giỏ hàng (hành động chuyển đổi phụ). Bạn nên xem Hướng dẫn tham khảo về sự kiện gtag.js.
set: Đặt các thông số chung cho tất cả sự kiện trên trang, chẳng hạn như đơn vị tiền tệ.
Ví dụ sau đây là một đoạn mã JavaScript của thẻ toàn trang web để gửi dữ liệu đến Google Ads. Giá trị trình giữ chỗ GOOGLE_CONVERSION_ID là một mã nhận dạng bằng số duy nhất cho một tài khoản nhà quảng cáo.
<!-- 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>
Đoạn mã thẻ Google chỉ nên xuất hiện một lần trên mỗi trang. Nếu đã có một phiên bản gtag.js, bạn nên thêm mã thẻ mới vào thẻ hiện có. Để gửi dữ liệu đến nhiều tài khoản, bạn có thể thêm một lệnh gọi vào lệnh "config" cho mỗi tài khoản mà bạn đang sử dụng, chỉ định mã lượt chuyển đổi của từng tài khoản, như minh hoạ trong ví dụ sau:
<!-- 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>
Thông tin khác về đoạn mã sự kiện và vị trí cài đặt đoạn mã này
Để tính năng theo dõi lượt chuyển đổi từ giao dịch mua hoạt động, bạn nên cài đặt đoạn mã sự kiện mua hàng trên chính trang chuyển đổi. Đây thường là trang xác nhận đơn đặt hàng. Bạn có thể đặt đoạn mã sự kiện ở mọi vị trí trong mã, sau đoạn mã thẻ toàn cầu. Bạn nên đặt đoạn mã sự kiện cho hành động chuyển đổi phụ (ví dụ: thêm vào giỏ hàng) trong các trang tương ứng.
Trong ví dụ về đoạn mã dưới đây, AW-CONVERSION_ID và gTag_developer_ID đại diện cho mã chuyển đổi dành riêng cho tài khoản Google Ads của bạn và tài khoản nhà phát triển Google Tag, còn AW-CONVERSION_LABEL đại diện cho nhãn chuyển đổi (đây là nhãn dành riêng cho mỗi hành động chuyển đổi):
<!-- 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>
Mặc dù một số thông số là không bắt buộc, nhưng bạn nên đưa nhiều thông tin nhất có thể cho mỗi sự kiện. Tìm hiểu thêm về những thông số có sẵn cho từng loại sự kiện.
Thông số cung cấp thêm thông tin về cách người dùng tương tác với trang web hoặc ứng dụng của bạn.
Nếu muốn đo lường một sự kiện chuyển đổi dựa trên lượt nhấp (ví dụ: trên một nút hoặc một phản hồi linh động cho một trang web sử dụng AJAX), bạn cũng có thể sử dụng đoạn mã sau:
<!-- 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>
Triển khai Consent API (còn gọi là Chế độ đồng ý)
Thẻ Google có API Chế độ đồng ý tích hợp để quản lý sự đồng ý của người dùng. Nền tảng này có thể phân biệt sự đồng ý của người dùng đối với cookie cho mục đích quảng cáo với sự đồng ý đối với cookie cho mục đích phân tích.
Kết quả dự kiến là khách hàng nhận được ít nhất lệnh gọi gtag('consent', 'update' {...}) được tích hợp mà không cần khách hàng phải làm gì. Điều này sẽ đảm bảo thẻ Google (Google Ads, Floodlight, Google Analytics, Trình liên kết chuyển đổi) có thể đọc trạng thái đồng ý mới nhất của người dùng và đưa trạng thái đó vào các yêu cầu mạng gửi đến Google (thông qua tham số &gcs).
Các bước triển khai bổ sung sẽ là triển khai hoặc hỗ trợ nhà quảng cáo triển khai (ví dụ: thông qua giao diện người dùng) trạng thái gtag('consent', default' {...}) và bỏ chặn thẻ Google (ví dụ: không có điều kiện kích hoạt dựa trên sự đồng ý) để cho phép chế độ đồng ý kích hoạt các thẻ đó theo cách có nhận biết sự đồng ý.
Để biết thông tin chi tiết về cách triển khai, hãy xem bài viết Quản lý chế độ cài đặt về sự đồng ý (trên web).
Mẹo
Trong tài khoản người quản lý Google Ads,bạn có thể theo dõi lượt chuyển đổi trên tất cả các tài khoản quảng cáo bằng một thẻ mã chuyển đổi duy nhất. Xem thông tin về tính năng theo dõi lượt chuyển đổi trên nhiều tài khoản.
Cách tốt nhất để kiểm tra xem chế độ triển khai tính năng theo dõi lượt chuyển đổi có hoạt động hay không là truy cập vào một trong các trang web của người bán (hoặc một trang web thử nghiệm nội bộ) và thực hiện giao dịch mua thực tế. Sau đó, bạn có thể quan sát trong công cụ Tag Assistant của Google để sử dụng hướng dẫn khắc phục sự cố này nhằm xác minh rằng Google Ads đã thấy thẻ của bạn và đang ghi lại lượt chuyển đổi thành công. Để biết thêm thông tin về cách khắc phục vấn đề, hãy xem bài viết khắc phục vấn đề về việc gắn thẻ trên toàn trang web.
Bạn có thể bổ sung thẻ chuyển đổi trước đó bằng tính năng lượt chuyển đổi nâng cao. Tính năng này có thể cải thiện độ chính xác của kết quả đo lường lượt chuyển đổi và giúp bạn đặt giá thầu hiệu quả hơn. Tìm hiểu thêm về cách thiết lập tính năng lượt chuyển đổi nâng cao. Trước khi triển khai tính năng lượt chuyển đổi nâng cao, bạn phải đảm bảo rằng người bán của bạn có thể tuân thủ Chính sách về dữ liệu khách hàng áp dụng cho tính năng lượt chuyển đổi nâng cao trong Google Ads.