Skip to content

Commit 3dbd1d0

Browse files
committed
AdWords v201409 release
1 parent aceb992 commit 3dbd1d0

File tree

118 files changed

+8464
-108
lines changed

Some content is hidden

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

118 files changed

+8464
-108
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2.1.0 - 10/09/2014
2+
* Added support for v201409 of the AdWords/DoubleClick Ad Exchange Client
3+
Library.
4+
* Added convenience method for setting Client Customer Id to AdWordsClient.
5+
* Added ReportDownloader convenience methods.
6+
* Fixed upload_offline_conversions example. (Fixed issue #24)
7+
* Fixed issue creating complex types. (Fixed issue #18)
8+
19
2.0.2 - 09/03/2014
210
=================
311
* Added Ad Customizer example for AdWords.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ adwords_client = adwords.AdWordsClient.LoadFromStorage()
4545
dfp_client = dfp.DfpClient.LoadFromStorage('C:\My\Directory\googleads.yaml')
4646
```
4747

48+
####How do I change the Client Customer Id at runtime?
49+
You can change the Client Customer Id with the following:
50+
51+
```
52+
adwords_client = AdWordsClient.LoadFromStorage()
53+
adwords_client.SetClientCustomerId('my_client_customer_id')
54+
```
55+
56+
4857
##Where do I submit bug reports and/or feature requests?
4958

5059
Use the issue tracker at:
@@ -55,6 +64,7 @@ other news:
5564

5665
https://plus.google.com/+GoogleAdsDevelopers
5766

67+
5868
##How do I log SOAP interactions?
5969
The library uses Python's built in logging framework. If you wish to log your
6070
SOAP interactions to stdout, you can do the following:
@@ -65,6 +75,7 @@ logging.getLogger('suds.transport').setLevel(logging.DEBUG)
6575
If you wish to log to a file, you'll need to attach a log handler to this source
6676
which is configured to write the output to a file.
6777

78+
6879
##I'm familiar with suds. Can I use suds features with this library?
6980
Yes, you can. The services returned by the `client.GetService()` functions all
7081
have a reference to the underlying suds client stored in the `suds_client`
@@ -101,6 +112,7 @@ suds_client.set_options(
101112
suds_client.service.mutate([operation])
102113
```
103114

115+
104116
##External Dependencies:
105117

106118

examples/adwords/v201402/advanced_operations/upload_offline_conversions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141

4242
def main(client, conversion_name, click_id, conversion_time, conversion_value):
4343
# Initialize appropriate services.
44-
conversion_tracker_service = client.GetConversionTrackerService(
45-
version='v201402')
44+
conversion_tracker_service = client.GetService('ConversionTrackerService',
45+
version='v201402')
4646

47-
offline_conversion_feed_service = client.GetOfflineConversionFeedService(
48-
version='v201402')
47+
offline_conversion_feed_service = client.GetService(
48+
'OfflineConversionFeedService', version='v201402')
4949

5050
# Once created, this entry will be visible under
5151
# Tools and Analysis->Conversion and will have "Source = Import".
@@ -64,7 +64,7 @@ def main(client, conversion_name, click_id, conversion_time, conversion_value):
6464

6565
response = conversion_tracker_service.mutate(
6666
[upload_conversion_operation])
67-
new_upload_conversion = response['value'][0]
67+
new_upload_conversion = response['value']
6868

6969
print ('New upload conversion type with name \'%s\' and ID \'%s\' was '
7070
'created.' % (new_upload_conversion['name'],
@@ -85,7 +85,7 @@ def main(client, conversion_name, click_id, conversion_time, conversion_value):
8585

8686
offline_conversion_response = offline_conversion_feed_service.mutate(
8787
[offline_conversion_operation])
88-
new_feed = offline_conversion_response['value'][0]
88+
new_feed = offline_conversion_response['value']
8989

9090
print ('Uploaded offline conversion value of \'%s\' for Google Click ID '
9191
'\'%s\' to \'%s\'.' % (new_feed['conversionValue'],

examples/adwords/v201406/advanced_operations/upload_offline_conversions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141

4242
def main(client, conversion_name, click_id, conversion_time, conversion_value):
4343
# Initialize appropriate services.
44-
conversion_tracker_service = client.GetConversionTrackerService(
45-
version='v201406')
44+
conversion_tracker_service = client.GetService('ConversionTrackerService',
45+
version='v201406')
4646

47-
offline_conversion_feed_service = client.GetOfflineConversionFeedService(
48-
version='v201406')
47+
offline_conversion_feed_service = client.GetService(
48+
'OfflineConversionFeedService', version='v201406')
4949

5050
# Once created, this entry will be visible under
5151
# Tools and Analysis->Conversion and will have "Source = Import".
@@ -64,7 +64,7 @@ def main(client, conversion_name, click_id, conversion_time, conversion_value):
6464

6565
response = conversion_tracker_service.mutate(
6666
[upload_conversion_operation])
67-
new_upload_conversion = response['value'][0]
67+
new_upload_conversion = response['value']
6868

6969
print ('New upload conversion type with name \'%s\' and ID \'%s\' was '
7070
'created.' % (new_upload_conversion['name'],
@@ -85,7 +85,7 @@ def main(client, conversion_name, click_id, conversion_time, conversion_value):
8585

8686
offline_conversion_response = offline_conversion_feed_service.mutate(
8787
[offline_conversion_operation])
88-
new_feed = offline_conversion_response['value'][0]
88+
new_feed = offline_conversion_response['value']
8989

9090
print ('Uploaded offline conversion value of \'%s\' for Google Click ID '
9191
'\'%s\' to \'%s\'.' % (new_feed['conversionValue'],
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 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 retrieves the report download stream.
18+
19+
To get report fields, run get_report_fields.py.
20+
21+
The LoadFromStorage method is pulling credentials and properties from a
22+
"googleads.yaml" file. By default, it looks for this file in your home
23+
directory. For more information, see the "Caching authentication information"
24+
section of our README.
25+
26+
Tags: ReportDefinitionService.mutate
27+
Api: AdWordsOnly
28+
"""
29+
30+
__author__ = 'Mark Saniscalchi'
31+
32+
import logging
33+
import sys
34+
35+
from googleads import adwords
36+
import StringIO
37+
38+
logging.basicConfig(level=logging.INFO)
39+
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
40+
41+
42+
def main(client):
43+
report_downloader = client.GetReportDownloader(version='v201406')
44+
45+
# Create report definition.
46+
report = {
47+
'reportName': 'Last 7 days CRITERIA_PERFORMANCE_REPORT',
48+
'dateRangeType': 'LAST_7_DAYS',
49+
'reportType': 'CRITERIA_PERFORMANCE_REPORT',
50+
'downloadFormat': 'CSV',
51+
'selector': {
52+
'fields': ['CampaignId', 'AdGroupId', 'Id', 'CriteriaType',
53+
'Criteria', 'Impressions', 'Clicks', 'Cost']
54+
},
55+
# Enable to get rows with zero impressions.
56+
'includeZeroImpressions': 'false'
57+
}
58+
59+
# Retrieve the report stream and print it out
60+
report_data = StringIO.StringIO()
61+
stream_data = report_downloader.DownloadReportAsStream(report)
62+
63+
try:
64+
while True:
65+
chunk = stream_data.read(adwords._CHUNK_SIZE)
66+
if not chunk: break
67+
report_data.write(chunk.decode() if sys.version_info[0] == 3
68+
and getattr(report_data, 'mode', 'w') == 'w' else chunk)
69+
print report_data.getvalue()
70+
finally:
71+
report_data.close()
72+
stream_data.close()
73+
74+
75+
if __name__ == '__main__':
76+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
77+
main(adwords_client)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 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 downloads a criteria performance report as a string with AWQL.
18+
19+
To get report fields, run get_report_fields.py.
20+
21+
The LoadFromStorage method is pulling credentials and properties from a
22+
"googleads.yaml" file. By default, it looks for this file in your home
23+
directory. For more information, see the "Caching authentication information"
24+
section of our README.
25+
26+
Tags: ReportDefinitionService.mutate
27+
Api: AdWordsOnly
28+
"""
29+
30+
__author__ = ('[email protected] (Kevin Winter)'
31+
'Joseph DiLallo')
32+
33+
import logging
34+
import sys
35+
36+
from googleads import adwords
37+
import StringIO
38+
39+
logging.basicConfig(level=logging.INFO)
40+
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
41+
42+
# Specify where to download the file here.
43+
PATH = '/tmp/report_download.csv'
44+
45+
46+
def main(client):
47+
# Initialize appropriate service.
48+
report_downloader = client.GetReportDownloader(version='v201406')
49+
50+
# Create report query.
51+
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
52+
'Impressions, Clicks, Cost '
53+
'FROM CRITERIA_PERFORMANCE_REPORT '
54+
'WHERE Status IN [ENABLED, PAUSED] '
55+
'DURING LAST_7_DAYS')
56+
57+
print report_downloader.DownloadReportAsStringWithAwql(report_query, 'CSV')
58+
59+
# Retrieve the report stream and print it out
60+
report_data = StringIO.StringIO()
61+
stream_data = report_downloader.DownloadReportAsStreamWithAwql(report_query,
62+
'CSV')
63+
64+
try:
65+
while True:
66+
chunk = stream_data.read(adwords._CHUNK_SIZE)
67+
if not chunk: break
68+
report_data.write(chunk.decode() if sys.version_info[0] == 3
69+
and getattr(report_data, 'mode', 'w') == 'w' else chunk)
70+
print report_data.getvalue()
71+
finally:
72+
report_data.close()
73+
stream_data.close()
74+
75+
76+
if __name__ == '__main__':
77+
# Initialize client object.
78+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
79+
80+
main(adwords_client)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 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 downloads a criteria performance report as a string.
18+
19+
To get report fields, run get_report_fields.py.
20+
21+
The LoadFromStorage method is pulling credentials and properties from a
22+
"googleads.yaml" file. By default, it looks for this file in your home
23+
directory. For more information, see the "Caching authentication information"
24+
section of our README.
25+
26+
Tags: ReportDefinitionService.mutate
27+
Api: AdWordsOnly
28+
"""
29+
30+
__author__ = 'Mark Saniscalchi'
31+
32+
import logging
33+
import sys
34+
35+
from googleads import adwords
36+
37+
logging.basicConfig(level=logging.INFO)
38+
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
39+
40+
41+
def main(client):
42+
report_downloader = client.GetReportDownloader(version='v201406')
43+
44+
# Create report definition.
45+
report = {
46+
'reportName': 'Last 7 days CRITERIA_PERFORMANCE_REPORT',
47+
'dateRangeType': 'LAST_7_DAYS',
48+
'reportType': 'CRITERIA_PERFORMANCE_REPORT',
49+
'downloadFormat': 'CSV',
50+
'selector': {
51+
'fields': ['CampaignId', 'AdGroupId', 'Id', 'CriteriaType',
52+
'Criteria', 'Impressions', 'Clicks', 'Cost']
53+
},
54+
# Enable to get rows with zero impressions.
55+
'includeZeroImpressions': 'false'
56+
}
57+
58+
# Print out the report as a string
59+
print report_downloader.DownloadReportAsString(report)
60+
61+
62+
if __name__ == '__main__':
63+
adwords_client = adwords.AdWordsClient.LoadFromStorage()
64+
main(adwords_client)

0 commit comments

Comments
 (0)