Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/AdvancedOperations/AddPerformanceMaxCampaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@
use Google\Ads\GoogleAds\V25\Enums\BudgetDeliveryMethodEnum\BudgetDeliveryMethod;
use Google\Ads\GoogleAds\V25\Enums\CampaignStatusEnum\CampaignStatus;
use Google\Ads\GoogleAds\V25\Enums\EuPoliticalAdvertisingStatusEnum\EuPoliticalAdvertisingStatus;
use Google\Ads\GoogleAds\V25\Enums\MessagingRestrictionTypeEnum\MessagingRestrictionType;
use Google\Ads\GoogleAds\V25\Errors\GoogleAdsError;
use Google\Ads\GoogleAds\V25\Resources\Asset;
use Google\Ads\GoogleAds\V25\Resources\AssetGroup;
use Google\Ads\GoogleAds\V25\Resources\AssetGroupAsset;
use Google\Ads\GoogleAds\V25\Resources\AssetGroupSignal;
use Google\Ads\GoogleAds\V25\Resources\Campaign;
use Google\Ads\GoogleAds\V25\Resources\Campaign\AssetAutomationSetting;
use Google\Ads\GoogleAds\V25\Resources\Campaign\MessagingRestriction;
use Google\Ads\GoogleAds\V25\Resources\Campaign\TextGuidelines;
use Google\Ads\GoogleAds\V25\Resources\CampaignAsset;
use Google\Ads\GoogleAds\V25\Resources\CampaignBudget;
use Google\Ads\GoogleAds\V25\Resources\CampaignCriterion;
Expand Down Expand Up @@ -307,6 +310,26 @@ private static function createPerformanceMaxCampaignOperation(
int $customerId,
bool $brandGuidelinesEnabled
): MutateOperation {
// [START add_performance_max_text_guidelines]
$textGuidelines = new TextGuidelines(
[
// Specifies a list of terms that should not be used in any auto-generated
// text assets.
'term_exclusions' => ['cheap', 'free'],
// Specifies freeform messaging restriction prompts that will apply to all
// auto-generated text assets.
'messaging_restrictions' => [
new MessagingRestriction(
[
'restriction_text' => "Don't mention competitor names",
'restriction_type' => MessagingRestrictionType::RESTRICTION_BASED_EXCLUSION
]
)
]
]
);
// [END add_performance_max_text_guidelines]

// Creates a mutate operation that creates a campaign operation.
return new MutateOperation(
[
Expand Down Expand Up @@ -373,6 +396,9 @@ private static function createPerformanceMaxCampaignOperation(
// https://support.google.com/google-ads/answer/14934472.
'brand_guidelines_enabled' => $brandGuidelinesEnabled,

// Sets the text guidelines.
'text_guidelines' => $textGuidelines,

// Declare whether or not this campaign serves political ads targeting the EU.
'contains_eu_political_advertising' =>
EuPoliticalAdvertisingStatus::DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING,
Expand Down
Loading