Getting error
"error": "Call to undefined method
Google\\Ads\\GoogleAds\\V18\\Services\\CampaignConversionGoalOperation::setCreate()"
private function applyConversionGoals($googleAdsClient, $customerId,
$campaignResourceName, $conversionGoals)
{
if (empty($conversionGoals)) {
Log::warning("⚠️ No conversion goals provided for campaign: " .
$campaignResourceName);
return;
}
Log::info("🔍 Processing Conversion Goals: " . json_encode($conversionGoals
));
$operations = [];
foreach ($conversionGoals as $goal) {
if (!isset($goal['category']) || !isset($goal['origin'])) {
Log::error("🚨 Missing category or origin in goal: " . json_encode($goal));
continue;
}
$categoryKey = strtoupper($goal['category']);
$originKey = strtoupper($goal['origin']);
// Convert the category using the ConversionActionCategory enum.
try {
$categoryValue = ConversionActionCategory::value(strtoupper($goal['category'
]));
} catch (UnexpectedValueException $e) {
Log::error("🚨 Invalid conversion category provided: " . $categoryKey);
continue;
}
// Convert the origin using the ConversionOrigin enum.
try {
$originValue = ConversionOrigin::value($originKey);
} catch (UnexpectedValueException $e) {
Log::error("🚨 Invalid conversion origin provided: " . $originKey);
continue;
}
// Convert biddable flag to boolean.
$biddable = isset($goal['biddable']) ? filter_var($goal['biddable'],
FILTER_VALIDATE_BOOLEAN) : false;
try {
$conversionGoal = new CampaignConversionGoal([
'campaign' => $campaignResourceName,
'category' => $categoryValue,
'origin' => $originValue,
'biddable' => false,
]);
$operation = new CampaignConversionGoalOperation();
$operation->setCreate($conversionGoal);
$operations[] = $operation;
} catch (\Throwable $th) {
throw new Exception($th->getMessage());
Log::error("🔴 Error creating conversion goal for {$categoryKey}: " . $th->
getMessage());
}
}
if (empty($operations)) {
throw new Exception("No valid Conversion Goal operations created for
campaign: " . $campaignResourceName);
Log::warning("⚠️ No valid Conversion Goal operations created for campaign: "
. $campaignResourceName);
return;
}
try {
$mutateRequest = new MutateCampaignConversionGoalsRequest([
'customer_id' => $customerId,
'operations' => $operations,
]);
$campaignConversionGoalServiceClient = $googleAdsClient->
getCampaignConversionGoalServiceClient();
$response = $campaignConversionGoalServiceClient->
mutateCampaignConversionGoals($mutateRequest);
Log::info("✅ Conversion Goals Applied Successfully: " . json_encode(
$response->getResults()));
} catch (\Throwable $th) {
throw new Exception("🚨 Google Ads API Error in Conversion Goals: ". $th->
getMessage());
Log::error("🚨 Google Ads API Error in Conversion Goals: " . $th->getMessage
());
}
}
On Tuesday, February 25, 2025 at 7:55:38 PM UTC+5:30 Google Ads API Forum
Advisor wrote:
> Hi,
>
> Thank you for reaching out to the Google Ads API support team.
>
> Based on the information provided, I understand that you are attempting to
> override the default conversion goals at the campaign level using the
> Google Ads API V18 and facing issues. Please find the answers for your
> questions below:
>
> *1. Why does the campaign-level conversion goal override appear as
> account-default? Is it possible that if the override values match the
> account-level default settings, the UI shows account-default even though
> the override is applied?*
>
> - Google Ads automatically creates CustomerConversionGoal objects. You
> can set the *biddable* attribute for each goal to determine whether it
> should be an account-default goal
> <https://support.google.com/google-ads/answer/10995103#account_default>.
> Set *biddable* to *true* if Google Ads should optimize for conversion
> actions based on the goal's category and origin. Otherwise, set it to
> *false*. The values *true* and *false* correspond to the "Use as an
> account-default goal" and "Do not use as an account-default goal" options
> in the conversion action settings
>
> <https://support.google.com/google-ads/answer/10993988#edit_account_default>,
> respectively. I would recommend you to refer to this guide
>
> <https://developers.google.com/google-ads/api/docs/conversions/goals/customer-goals>
>
> for more detailed information.
>
> *2. Are there specific conditions (e.g., campaign objective or other
> settings) that must be met to ensure that the conversion goal override
> takes effect and is visible in the dashboard?*
>
> - No, there are no specific conditions other than setting the
> 'biddable' field to false. Upon checking the request body, I could see
> that
> you have set the 'biddable' field to 'true' under the conversion_goal
> which
> will automatically set the account default conversion goals.
>
> *3. Is there a propagation delay or a known issue in the Google Ads UI
> regarding the display of campaign-level conversion goals?*
>
> - No, there is no propagation delay or any issues in the Google Ads UI
> regarding the campaign level conversion goals. I would recommend you to
> refer to the documentation
>
> <https://developers.google.com/google-ads/api/docs/conversions/goals/campaign-goals#:~:text=The%20steps%20for%20creating%20and%20applying%20a%20custom%20goal%20to%20a%20campaign%20are%20as%20follows%3A>
>
> which explains the step by step process in applying the custom goals to
> campaign using the Google Ads API.
>
>
>
> Thanks,
>
> [image: Google Logo] Google Ads API Team
> Feedback
> How was our support today?
>
> [image: rating1]
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=1&entry.295079254=5004Q00002vH3omQAC>
>
> [image: rating2]
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=2&entry.295079254=5004Q00002vH3omQAC>
>
> [image: rating3]
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=3&entry.295079254=5004Q00002vH3omQAC>
>
> [image: rating4]
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=4&entry.295079254=5004Q00002vH3omQAC>
>
> [image: rating5]
> <https://docs.google.com/forms/d/e/1FAIpQLSeRhIg5VeThVmbcD0c5DTWTDjmpJuSktN8vFelEL7_KV_Orbg/viewform?usp=pp_url&entry.141427034=5&entry.295079254=5004Q00002vH3omQAC>
> [2025-02-25 14:25:01Z GMT] This message is in relation to case
> "ref:!00D1U01174p.!5004Q02vH3om:ref" (ADR-00289727)
>
>
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/adwords-api/cd8a20f6-5c6b-4b67-bb97-9629d201e209n%40googlegroups.com.