I used to upload offline conversion using following code in v201809 version as provided at https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201809/Remarketing/UploadOfflineConversions.php

$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build(); $session = (new AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->withClientCustomerId($customerid)->enablePartialFailure()->build(); $adWordsServices = new AdWordsServices(); $offlineConversionService = $adWordsServices->get($session, OfflineConversionFeedService::class); $conversionName="OfflineConv"; $feed = new OfflineConversionFeed(); $feed->setConversionName($conversionName); $feed->setConversionTime($conversionTime); $feed->setConversionValue($conversionValue); $feed->setGoogleClickId($gclid); $offlineConversionOperation = new OfflineConversionFeedOperation(); $offlineConversionOperation->setOperator(Operator::ADD); $offlineConversionOperation->setOperand($feed); $offlineConversionOperations = [$offlineConversionOperation]; $result = $offlineConversionService->mutate($offlineConversionOperations); 

Now I am upgrading to V9, I have used the code as provided at https://github.com/googleads/google-ads-php/blob/main/examples/Remarketing/UploadOfflineConversion.php

$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build(); $googleAdsClient = (new GoogleAdsClientBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential)->build(); //$conversionName="OfflineConv"; $conversionName = ConversionActionType::WEBPAGE; $clickConversion = new ClickConversion([ 'conversion_action' => ResourceNames::forConversionAction($customerId, $conversionName), 'gclid' => $gclid, 'conversion_value' => $conversionValue, 'conversion_date_time' => $conversionTime, 'currency_code' => 'USD' ]); $conversionUploadServiceClient = $googleAdsClient->getConversionUploadServiceClient(); $result = $conversionUploadServiceClient->uploadClickConversions($customerid, [$clickConversion], true); 

The problem is when we set $conversionName="OfflineConv"; we get following error. Resource name 'customers/9025381111/conversionActions/OfflineConv' is malformed: expected 'customers/{customer_id}/conversionActions/{ConversionType.conversion_type_id}'., at conversions[0].conversion_action

and when we set $conversionName = ConversionActionType::WEBPAGE; we get following error. This customer does not have an import conversion action that matches the conversion action provided., at conversions[0].conversion_action

Can someone help me?

Tag:google-ads-api

4 comments.

  1. Arun Gangula

    You need to first create a click conversion

    click_conversion = adwords_client.get_type("ClickConversion") conversion_action_service = adwords_client.get_service('ConversionActionService') click_conversion.conversion_action = ( conversion_action_service.conversion_action_path( customer_id, conversion_action_id ) )

    The conversion_action_id is equivalent to conversion_name of previous version. You can find the id using following snippet

    ads: GoogleAdsServiceClient = self.adwords_client.get_service('GoogleAdsService') pages = ads.search(query="SELECT conversion_action.id, conversion_action.name FROM conversion_action where conversion_action.name={conversion_name}", customer_id={customer_id}) for page in pages: print(page.conversion_action)

    Then you upload the conversion

    click_conversion.gclid = gclid click_conversion.conversion_value = conversion_value click_conversion.conversion_date_time = conversion_time click_conversion.currency_code = currency_code conversion_upload_service = self.adwords_client.get_service("ConversionUploadService") request = self.adwords_client.get_type("UploadClickConversionsRequest") request.customer_id = customer_id request.conversions.append(click_conversion) request.partial_failure = True conversion_upload_response = ( conversion_upload_service.upload_click_conversions( request=request, ) ) uploaded_click_conversion = conversion_upload_response.results[0] print( f"Uploaded conversion that occurred at " f'"{uploaded_click_conversion.conversion_date_time}" from ' f'Google Click ID "{uploaded_click_conversion.gclid}" ' f'to "{uploaded_click_conversion.conversion_action}"' )
  2. Mikhail Alekseev

    ConversionName has been removed from V9, use $conversionActionId as in example on github.

    You need to try use parameter ctId from url your "OfflineConversions" in Google Ads UI as $conversionActionId.

    Or try the solution from here.

    For your example, replace this

    $conversionName = ConversionActionType::WEBPAGE;

    on this

    $conversionName = {ctId from url};
  3. Dave Davis

    Conversion Name must match the conversion action that you've already set up in your account. You're passing the enum value for the type.

    It should be something like $conversionName = "OfflineConversions" where "OfflineConversions" is exactly the name of the conversion in the conversions section of the web UI.

    1. Wasi

      First of all thank you for your response, and yes I'm using exact conversion name as appear in web interface. It's working in v201809 but in V9 I get the error Resource name 'customers/9025381111/conversionActions/OfflineConv' is malformed: expected 'customers/{customer_id}/conversionActions/{ConversionType.conversion_type_id}'., at conversions[0].conversion_action

Add a new comment.