Create campaing with specific goal settings

98 views
Skip to first unread message

Carlos Arnau

unread,
Oct 4, 2023, 6:23:33 AM10/4/23
to Google Ads API and AdWords API Forum
I'm currently trying to create my search campaigns with an specific goal, but after reading the documentation[1] and some messages[2] in this group, I cannot figure out how. I don't want to modify the goals of an existing campaign but create a new campaign with that goals from the start.

The conversion goal that I want to apply to my new campaigns is already created and I can fetch it with the google ads service, so I already have the resource name. Given this PHP snippet code and assuming that specifying a campaign goal should be added in the CampaignMutateOperation, where should I specify my custom goal?

return new MutateOperation([
    'campaign_operation' => new CampaignOperation([
        'create' => new Campaign([
            'name' => 'Test campaign',
            'resource_name' => ResourceNames::forCampaign(
                '1234',
                '-1'
            ),
            'campaign_budget' => ResourceNames::forCampaignBudget(
                '1234',
                '-10',
            ),
            'status' => CampaignStatus::ENABLED,
            'advertising_channel_type' => AdvertisingChannelType::SEARCH,
            'maximize_conversions' => new MaximizeConversions(),
            'network_settings' => new NetworkSettings([
                'target_google_search' => true,
                'target_search_network' => true,
                'target_content_network' => false,
                'target_partner_search_network' => false,
            ]),
        ]),
    ]),
]);

Thank you for your help.

Carlos Arnau

unread,
Oct 4, 2023, 9:50:04 AM10/4/23
to Google Ads API and AdWords API Forum
Hello,

I could add an specific goal to the campaign using the following snippet[1], but I've noticed that now I do have the default account goals as well although I only updated it to include my custom goal. Does the api provide any way to remove the default ones?

Thank you!

[1]
return new MutateOperation([
    'conversion_goal_campaign_config_operation' => new ConversionGoalCampaignConfigOperation([
        'update_mask' => (new FieldMask())->setPaths(['custom_conversion_goal']),
        'update' => new ConversionGoalCampaignConfig([
            'resource_name' => ResourceNames::forConversionGoalCampaignConfig(
                '1',
                '-10'
            ),
            'campaign' => ResourceNames::forCampaign(
                '1',
                '-10'
            ),
            'custom_conversion_goal' => 'resource_name_of_custom_conversion_goal',
        ]),
    ]),
]);
Reply all
Reply to author
Forward
0 new messages