Skip to content

Commit 73bb968

Browse files
author
Nicholas Chen
committed
releasing v201605 of AdWords
1 parent df744af commit 73bb968

File tree

107 files changed

+9428
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+9428
-225
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
4.1.0 -- 5/26/2016
2+
* Added support for AdWords v201605.
3+
* Added new use_raw_enum_values keyword argument to the AdWords ReportDownloader
4+
utility.
5+
16
4.0.0 -- 5/17/2016
27
* Add support for DFP v201605.
38
* Removed examples for DFP v201505.

examples/adwords/adwords_appengine_demo/handlers/api_handler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ def AddBudget(self, client_customer_id, micro_amount):
8787
'operator': 'ADD',
8888
'operand': {
8989
'name': 'Budget #%s' % time.time(),
90-
'period': 'DAILY',
9190
'amount': {
9291
'microAmount': micro_amount
9392
},

examples/adwords/v201509/optimization/estimate_keyword_traffic.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,34 +93,35 @@ def main(client):
9393
continue
9494

9595
# Find the mean of the min and max values.
96-
mean_avg_cpc = (calc_mean(estimate['min']['averageCpc']['microAmount'],
97-
estimate['max']['averageCpc']['microAmount'])
96+
mean_avg_cpc = (_CalculateMean(estimate['min']['averageCpc']['microAmount'],
97+
estimate['max']['averageCpc']['microAmount'])
9898
if 'averageCpc' in estimate['min'] else 'N/A')
99-
mean_avg_pos = calc_mean(estimate['min']['averagePosition'],
100-
estimate['max']['averagePosition'])
101-
mean_clicks = calc_mean(estimate['min']['clicksPerDay'],
102-
estimate['max']['clicksPerDay'])
103-
mean_total_cost = calc_mean(estimate['min']['totalCost']['microAmount'],
104-
estimate['max']['totalCost']['microAmount'])
99+
mean_avg_pos = _CalculateMean(estimate['min']['averagePosition'],
100+
estimate['max']['averagePosition'])
101+
mean_clicks = _CalculateMean(estimate['min']['clicksPerDay'],
102+
estimate['max']['clicksPerDay'])
103+
mean_total_cost = _CalculateMean(
104+
estimate['min']['totalCost']['microAmount'],
105+
estimate['max']['totalCost']['microAmount'])
105106

106107
print ('Results for the keyword with text \'%s\' and match type \'%s\':'
107108
% (keyword['text'], keyword['matchType']))
108-
print ' Estimated average CPC: %s' % mean_avg_cpc
109-
print ' Estimated ad position: %s' % mean_avg_pos
110-
print ' Estimated daily clicks: %s' % mean_clicks
111-
print ' Estimated daily cost: %s' % mean_total_cost
109+
print ' Estimated average CPC: %s' % _FormatMean(mean_avg_cpc)
110+
print ' Estimated ad position: %s' % _FormatMean(mean_avg_pos)
111+
print ' Estimated daily clicks: %s' % _FormatMean(mean_clicks)
112+
print ' Estimated daily cost: %s' % _FormatMean(mean_total_cost)
112113

113114

114-
def fmt_mean(mean):
115-
if mean:
116-
return '%.2f' % mean
115+
def _CalculateMean(min_est, max_est):
116+
if min_est and max_est:
117+
return (float(min_est) + float(max_est)) / 2.0
117118
else:
118119
return None
119120

120121

121-
def calc_mean(min_est, max_est):
122-
if min_est and max_est:
123-
return (float(min_est) + float(max_est)) / 2.0
122+
def _FormatMean(mean):
123+
if mean:
124+
return '%.2f' % mean
124125
else:
125126
return None
126127

examples/adwords/v201601/optimization/estimate_keyword_traffic.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,34 +93,35 @@ def main(client):
9393
continue
9494

9595
# Find the mean of the min and max values.
96-
mean_avg_cpc = (calc_mean(estimate['min']['averageCpc']['microAmount'],
97-
estimate['max']['averageCpc']['microAmount'])
96+
mean_avg_cpc = (_CalculateMean(estimate['min']['averageCpc']['microAmount'],
97+
estimate['max']['averageCpc']['microAmount'])
9898
if 'averageCpc' in estimate['min'] else 'N/A')
99-
mean_avg_pos = calc_mean(estimate['min']['averagePosition'],
100-
estimate['max']['averagePosition'])
101-
mean_clicks = calc_mean(estimate['min']['clicksPerDay'],
102-
estimate['max']['clicksPerDay'])
103-
mean_total_cost = calc_mean(estimate['min']['totalCost']['microAmount'],
104-
estimate['max']['totalCost']['microAmount'])
99+
mean_avg_pos = _CalculateMean(estimate['min']['averagePosition'],
100+
estimate['max']['averagePosition'])
101+
mean_clicks = _CalculateMean(estimate['min']['clicksPerDay'],
102+
estimate['max']['clicksPerDay'])
103+
mean_total_cost = _CalculateMean(
104+
estimate['min']['totalCost']['microAmount'],
105+
estimate['max']['totalCost']['microAmount'])
105106

106107
print ('Results for the keyword with text \'%s\' and match type \'%s\':'
107108
% (keyword['text'], keyword['matchType']))
108-
print ' Estimated average CPC: %s' % mean_avg_cpc
109-
print ' Estimated ad position: %s' % mean_avg_pos
110-
print ' Estimated daily clicks: %s' % mean_clicks
111-
print ' Estimated daily cost: %s' % mean_total_cost
109+
print ' Estimated average CPC: %s' % _FormatMean(mean_avg_cpc)
110+
print ' Estimated ad position: %s' % _FormatMean(mean_avg_pos)
111+
print ' Estimated daily clicks: %s' % _FormatMean(mean_clicks)
112+
print ' Estimated daily cost: %s' % _FormatMean(mean_total_cost)
112113

113114

114-
def fmt_mean(mean):
115-
if mean:
116-
return '%.2f' % mean
115+
def _CalculateMean(min_est, max_est):
116+
if min_est and max_est:
117+
return (float(min_est) + float(max_est)) / 2.0
117118
else:
118119
return None
119120

120121

121-
def calc_mean(min_est, max_est):
122-
if min_est and max_est:
123-
return (float(min_est) + float(max_est)) / 2.0
122+
def _FormatMean(mean):
123+
if mean:
124+
return '%.2f' % mean
124125
else:
125126
return None
126127

examples/adwords/v201603/optimization/estimate_keyword_traffic.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,34 +93,35 @@ def main(client):
9393
continue
9494

9595
# Find the mean of the min and max values.
96-
mean_avg_cpc = (calc_mean(estimate['min']['averageCpc']['microAmount'],
97-
estimate['max']['averageCpc']['microAmount'])
96+
mean_avg_cpc = (_CalculateMean(estimate['min']['averageCpc']['microAmount'],
97+
estimate['max']['averageCpc']['microAmount'])
9898
if 'averageCpc' in estimate['min'] else 'N/A')
99-
mean_avg_pos = calc_mean(estimate['min']['averagePosition'],
100-
estimate['max']['averagePosition'])
101-
mean_clicks = calc_mean(estimate['min']['clicksPerDay'],
102-
estimate['max']['clicksPerDay'])
103-
mean_total_cost = calc_mean(estimate['min']['totalCost']['microAmount'],
104-
estimate['max']['totalCost']['microAmount'])
99+
mean_avg_pos = _CalculateMean(estimate['min']['averagePosition'],
100+
estimate['max']['averagePosition'])
101+
mean_clicks = _CalculateMean(estimate['min']['clicksPerDay'],
102+
estimate['max']['clicksPerDay'])
103+
mean_total_cost = _CalculateMean(
104+
estimate['min']['totalCost']['microAmount'],
105+
estimate['max']['totalCost']['microAmount'])
105106

106107
print ('Results for the keyword with text \'%s\' and match type \'%s\':'
107108
% (keyword['text'], keyword['matchType']))
108-
print ' Estimated average CPC: %s' % mean_avg_cpc
109-
print ' Estimated ad position: %s' % mean_avg_pos
110-
print ' Estimated daily clicks: %s' % mean_clicks
111-
print ' Estimated daily cost: %s' % mean_total_cost
109+
print ' Estimated average CPC: %s' % _FormatMean(mean_avg_cpc)
110+
print ' Estimated ad position: %s' % _FormatMean(mean_avg_pos)
111+
print ' Estimated daily clicks: %s' % _FormatMean(mean_clicks)
112+
print ' Estimated daily cost: %s' % _FormatMean(mean_total_cost)
112113

113114

114-
def fmt_mean(mean):
115-
if mean:
116-
return '%.2f' % mean
115+
def _CalculateMean(min_est, max_est):
116+
if min_est and max_est:
117+
return (float(min_est) + float(max_est)) / 2.0
117118
else:
118119
return None
119120

120121

121-
def calc_mean(min_est, max_est):
122-
if min_est and max_est:
123-
return (float(min_est) + float(max_est)) / 2.0
122+
def _FormatMean(mean):
123+
if mean:
124+
return '%.2f' % mean
124125
else:
125126
return None
126127

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Examples for AdWords."""
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2016 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Account management examples."""
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2016 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This example illustrates how to create an account.
18+
19+
Note by default this account will only be accessible via its parent AdWords
20+
manager account..
21+
22+
The LoadFromStorage method is pulling credentials and properties from a
23+
"googleads.yaml" file. By default, it looks for this file in your home
24+
directory. For more information, see the "Caching authentication information"
25+
section of our README.
26+
27+
"""
28+
29+
30+
from datetime import datetime
31+
from googleads import adwords
32+
33+
34+
def main(client):
35+
# Initialize appropriate service.
36+
managed_customer_service = client.GetService(
37+
'ManagedCustomerService', version='v201605')
38+
39+
today = datetime.today().strftime('%Y%m%d %H:%M:%S')
40+
# Construct operations and add campaign.
41+
operations = [{
42+
'operator': 'ADD',
43+
'operand': {
44+
'name': 'Account created with ManagedCustomerService on %s' % today,
45+
'currencyCode': 'EUR',
46+
'dateTimeZone': 'Europe/London',
47+
}
48+
}]
49+
50+
# Create the account. It is possible to create multiple accounts with one
51+
# request by sending an array of operations.
52+
accounts = managed_customer_service.mutate(operations)
53+
54+
# Display results.
55+
for account in accounts['value']:
56+
print ('Account with customer ID \'%s\' was successfully created.'
57+
% account['customerId'])
58+
59+
60+
if __name__ == '__main__':
61+
# Initialize client object.
62+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
63+
main(adwords_client)
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2016 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This example gets the changes in the account during the last 24 hours.
18+
19+
The LoadFromStorage method is pulling credentials and properties from a
20+
"googleads.yaml" file. By default, it looks for this file in your home
21+
directory. For more information, see the "Caching authentication information"
22+
section of our README.
23+
24+
"""
25+
26+
27+
import datetime
28+
from googleads import adwords
29+
30+
31+
def main(client):
32+
# Initialize appropriate service.
33+
customer_sync_service = client.GetService(
34+
'CustomerSyncService', version='v201605')
35+
campaign_service = client.GetService('CampaignService', version='v201605')
36+
37+
# Construct selector and get all campaigns.
38+
selector = {
39+
'fields': ['Id', 'Name', 'Status']
40+
}
41+
campaigns = campaign_service.get(selector)
42+
campaign_ids = []
43+
if 'entries' in campaigns:
44+
for campaign in campaigns['entries']:
45+
campaign_ids.append(campaign['id'])
46+
else:
47+
print 'No campaigns were found.'
48+
return
49+
50+
# Construct selector and get all changes.
51+
today = datetime.datetime.today()
52+
yesterday = today - datetime.timedelta(1)
53+
selector = {
54+
'dateTimeRange': {
55+
'min': yesterday.strftime('%Y%m%d %H%M%S'),
56+
'max': today.strftime('%Y%m%d %H%M%S')
57+
},
58+
'campaignIds': campaign_ids
59+
}
60+
account_changes = customer_sync_service.get(selector)
61+
62+
# Display results.
63+
if account_changes:
64+
if 'lastChangeTimestamp' in account_changes:
65+
print 'Most recent changes: %s' % account_changes['lastChangeTimestamp']
66+
if account_changes['changedCampaigns']:
67+
for data in account_changes['changedCampaigns']:
68+
print ('Campaign with id \'%s\' has change status \'%s\'.'
69+
% (data['campaignId'], data['campaignChangeStatus']))
70+
if (data['campaignChangeStatus'] != 'NEW' and
71+
data['campaignChangeStatus'] != 'FIELDS_UNCHANGED'):
72+
if 'addedCampaignCriteria' in data:
73+
print (' Added campaign criteria: %s' %
74+
data['addedCampaignCriteria'])
75+
if 'removedCampaignCriteria' in data:
76+
print (' Removed campaign criteria: %s' %
77+
data['removedCampaignCriteria'])
78+
if 'changedAdGroups' in data:
79+
for ad_group_data in data['changedAdGroups']:
80+
print (' Ad group with id \'%s\' has change status \'%s\'.'
81+
% (ad_group_data['adGroupId'],
82+
ad_group_data['adGroupChangeStatus']))
83+
if ad_group_data['adGroupChangeStatus'] != 'NEW':
84+
if 'changedAds' in ad_group_data:
85+
print ' Changed ads: %s' % ad_group_data['changedAds']
86+
if 'changedCriteria' in ad_group_data:
87+
print (' Changed criteria: %s' %
88+
ad_group_data['changedCriteria'])
89+
if 'removedCriteria' in ad_group_data:
90+
print (' Removed criteria: %s' %
91+
ad_group_data['removedCriteria'])
92+
else:
93+
print 'No changes were found.'
94+
95+
96+
if __name__ == '__main__':
97+
# Initialize client object.
98+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
99+
main(adwords_client)

0 commit comments

Comments
 (0)