Upload Offline Conversion migration to V9
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?