Skip to content

Commit 90397e0

Browse files
committed
Update examples to add contains_eu_political_advertising
field on campaign creation Change-Id: I0d721da9a133351cb04e06046436761efd69164b
1 parent 6ada25d commit 90397e0

15 files changed

+376
-101
lines changed

examples/advanced_operations/add_app_campaign.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ def create_campaign(client, customer_id, budget_resource_name):
133133
campaign.app_campaign_setting.bidding_strategy_goal_type = (
134134
client.enums.AppCampaignBiddingStrategyGoalTypeEnum.OPTIMIZE_INSTALLS_TARGET_INSTALL_COST
135135
)
136+
137+
# Declare whether or not this campaign serves political ads targeting the
138+
# EU. Valid values are:
139+
# CONTAINS_EU_POLITICAL_ADVERTISING
140+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
141+
campaign.contains_eu_political_advertising = (
142+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
143+
)
144+
136145
# Optional fields
137146
campaign.start_date = (datetime.now() + timedelta(1)).strftime("%Y%m%d")
138147
campaign.end_date = (datetime.now() + timedelta(365)).strftime("%Y%m%d")

examples/advanced_operations/add_dynamic_search_ads.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ def create_campaign(client, customer_id, budget_resource_name):
107107
# search ads setting domain name and language.
108108
campaign.dynamic_search_ads_setting.domain_name = "example.com"
109109
campaign.dynamic_search_ads_setting.language_code = "en"
110+
111+
# Declare whether or not this campaign serves political ads targeting the
112+
# EU. Valid values are:
113+
# CONTAINS_EU_POLITICAL_ADVERTISING
114+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
115+
campaign.contains_eu_political_advertising = (
116+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
117+
)
118+
110119
# Optional: Sets the start and end dates for the campaign, beginning one day
111120
# from now and ending a month from now.
112121
campaign.start_date = (datetime.now() + timedelta(days=1)).strftime(

examples/advanced_operations/add_performance_max_campaign.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ def create_performance_max_campaign_operation(
256256
customer_id, _BUDGET_TEMPORARY_ID
257257
)
258258

259+
# Declare whether or not this campaign serves political ads targeting the
260+
# EU. Valid values are:
261+
# CONTAINS_EU_POLITICAL_ADVERTISING
262+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
263+
campaign.contains_eu_political_advertising = (
264+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
265+
)
266+
259267
# Optional fields
260268
campaign.start_date = (datetime.now() + timedelta(1)).strftime("%Y%m%d")
261269
campaign.end_date = (datetime.now() + timedelta(365)).strftime("%Y%m%d")

examples/advanced_operations/add_smart_campaign.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,14 @@ def create_smart_campaign_operation(client, customer_id):
554554
customer_id, _BUDGET_TEMPORARY_ID
555555
)
556556

557+
# Declare whether or not this campaign serves political ads targeting the
558+
# EU. Valid values are:
559+
# CONTAINS_EU_POLITICAL_ADVERTISING
560+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
561+
campaign.contains_eu_political_advertising = (
562+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
563+
)
564+
557565
return mutate_operation
558566
# [END add_smart_campaign_3]
559567

examples/advanced_operations/use_portfolio_bidding_strategy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def main(client, customer_id):
9797
campaign.network_settings.target_search_network = True
9898
campaign.network_settings.target_content_network = False
9999
campaign.network_settings.target_partner_search_network = False
100+
campaign.contains_eu_political_advertising = (
101+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
102+
)
100103
# [END use_portfolio_bidding_strategy_2]
101104

102105
# Add the campaign.

examples/basic_operations/add_campaigns.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,14 @@ def main(client: GoogleAdsClient, customer_id: str) -> None:
113113
# Enable Display Expansion on Search campaigns. For more details see:
114114
# https://support.google.com/google-ads/answer/7193800
115115
campaign.network_settings.target_content_network = True
116-
# [END add_campaigns_1]
116+
117+
# Declare whether or not this campaign serves political ads targeting the
118+
# EU. Valid values are:
119+
# CONTAINS_EU_POLITICAL_ADVERTISING
120+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
121+
campaign.contains_eu_political_advertising = (
122+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
123+
)
117124

118125
# Optional: Set the start date.
119126
start_time: datetime.date = datetime.date.today() + datetime.timedelta(
@@ -124,6 +131,7 @@ def main(client: GoogleAdsClient, customer_id: str) -> None:
124131
# Optional: Set the end date.
125132
end_time: datetime.date = start_time + datetime.timedelta(weeks=4)
126133
campaign.end_date = datetime.date.strftime(end_time, _DATE_FORMAT)
134+
# [END add_campaigns_1]
127135

128136
# Add the campaign.
129137
campaign_response: MutateCampaignsResponse

examples/campaign_management/add_complete_campaigns_using_batch_job.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,14 @@ def build_campaign_operation(
401401
client.copy_from(campaign.manual_cpc, client.get_type("ManualCpc"))
402402
campaign.campaign_budget = campaign_budget_resource_name
403403

404+
# Declare whether or not this campaign serves political ads targeting the
405+
# EU. Valid values are:
406+
# CONTAINS_EU_POLITICAL_ADVERTISING
407+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
408+
campaign.contains_eu_political_advertising = (
409+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
410+
)
411+
404412
return campaign_operation
405413

406414

examples/misc/campaign_report_to_csv.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
from google.ads.googleads.client import GoogleAdsClient
3636
from google.ads.googleads.errors import GoogleAdsException
37-
from google.ads.googleads.v20.services.services.google_ads_service.client import (
37+
from google.ads.googleads.v20.services.services.google_ads_service import (
3838
GoogleAdsServiceClient,
3939
)
4040
from google.ads.googleads.v20.services.types.google_ads_service import (
@@ -50,6 +50,7 @@
5050
customer.descriptive_name,
5151
segments.date,
5252
campaign.name,
53+
campaign.contains_eu_political_advertising,
5354
metrics.impressions,
5455
metrics.clicks,
5556
metrics.cost_micros
@@ -95,6 +96,7 @@ def main(
9596
"Account",
9697
"Date",
9798
"Campaign",
99+
"Contains EU Political Advertising",
98100
"Impressions",
99101
"Clicks",
100102
"Cost",
@@ -115,6 +117,7 @@ def main(
115117
row.customer.descriptive_name,
116118
row.segments.date,
117119
row.campaign.name,
120+
row.campaign.contains_eu_political_advertising.name,
118121
row.metrics.impressions,
119122
row.metrics.clicks,
120123
row.metrics.cost_micros,

examples/remarketing/add_merchant_center_dynamic_remarketing_campaign.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ def create_campaign(
153153
).campaign_budget_path(customer_id, str(campaign_budget_id))
154154
client.copy_from(campaign.manual_cpc, client.get_type("ManualCpc"))
155155

156+
# Declare whether or not this campaign serves political ads targeting the
157+
# EU. Valid values are:
158+
# CONTAINS_EU_POLITICAL_ADVERTISING
159+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
160+
campaign.contains_eu_political_advertising = (
161+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
162+
)
163+
156164
# Issues a mutate request to add the campaign.
157165
campaign_response: MutateCampaignsResponse = (
158166
campaign_service.mutate_campaigns(

examples/shopping_ads/add_performance_max_retail_campaign.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,14 @@ def create_performance_max_campaign_operation(
391391
customer_id, _BUDGET_TEMPORARY_ID
392392
)
393393

394+
# Declare whether or not this campaign serves political ads targeting the
395+
# EU. Valid values are:
396+
# CONTAINS_EU_POLITICAL_ADVERTISING
397+
# DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
398+
campaign.contains_eu_political_advertising = (
399+
client.enums.EuPoliticalAdvertisingStatusEnum.DOES_NOT_CONTAIN_EU_POLITICAL_ADVERTISING
400+
)
401+
394402
# Optional fields
395403
campaign.start_date = (datetime.now() + timedelta(1)).strftime("%Y%m%d")
396404
campaign.end_date = (datetime.now() + timedelta(365)).strftime("%Y%m%d")

0 commit comments

Comments
 (0)