Page Summary
-
Enabling conversion tracking in your Google Ads conversion account is essential for recording conversions.
-
You can check your conversion tracking setup and status by querying the
Customerresource for theConversionTrackingSetting. -
To enable conversion tracking if it's not active, you need to create at least one
ConversionActionin your Google Ads conversion account. -
Cross-account conversion tracking allows a manager account to manage conversion actions for client accounts, with specific requirements and caveats to consider.
-
Different conversion action types require specific setups and have varying validation rules for their attributes.
You must enable conversion tracking in your Google Ads conversion account in order to record conversions. This guide provides details on how to confirm whether conversion tracking is enabled, enable it if it isn't enabled already, and retrieve information about existing conversion actions.
Most conversion actions also require additional steps on your part to track them. For more information on the various conversion action types and their requirements, see the Create conversion actions guide.
Prepare to provide consent
It's critical that you confirm that you have permission to share conversion data with Google. This can be done in one of two ways:
- Configure account-level default consent settings. In the Google Ads UI, click Tools -> Data Manager -> Consent settings -> Default consent settings.
- Set the ClickConversion.consent field on each imported conversion.
Set up your website to track conversions
If you're starting your offline conversion import integration, the first step is to follow the steps in the Configure the Google tag for enhanced conversions for leads guide to configure your website to track enhanced conversions for leads. You can also use Google Tag Manager to configure your website by following the steps in the Configure Google Tag Manager for enhanced conversions for leads guide.
Enable conversion tracking in your Google Ads conversion account
Retrieve information about your conversion tracking setup
You can check your account's conversion tracking setup and confirm conversion
tracking is enabled by querying the Customer resource
for the ConversionTrackingSetting.
Issue the following query with
GoogleAdsService.SearchStream:
SELECT
customer.conversion_tracking_setting.google_ads_conversion_customer,
customer.conversion_tracking_setting.conversion_tracking_status,
customer.conversion_tracking_setting.conversion_tracking_id,
customer.conversion_tracking_setting.cross_account_conversion_tracking_id
FROM customer
The google_ads_conversion_customer field indicates the Google Ads account that
creates and manages conversions for this customer. For customers using
cross-account conversion tracking,
this is the ID of a manager account. The Google Ads conversion customer ID should be
given as the customer_id in Google Ads API requests to create and manage conversions.
Note that this field is populated even if conversion tracking is not enabled.
The
conversion_tracking_status
field indicates whether conversion tracking is enabled and whether the account
is using cross-account conversion tracking.
Create a conversion action under the Google Ads conversion customer
If the conversion_tracking_status value is NOT_CONVERSION_TRACKED,
conversion tracking is not enabled for the account. Enable conversion tracking
by creating at least one ConversionAction in
the Google Ads conversion account, like in the following example. Alternatively, you
can create a conversion action in the UI by following the instructions in the
Help Center for the
conversion type you want to enable.
Note that enhanced conversions are enabled automatically when sent through the Google Ads API, but they can be disabled through the Google Ads UI.
Code example
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.V22.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 ); } }