google-adwords-api 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README +2 -1
- data/examples/v201109/account_management/create_account.rb +2 -2
- data/examples/v201109/account_management/get_account_alerts.rb +3 -3
- data/examples/v201109/account_management/get_account_changes.rb +2 -2
- data/examples/v201109/account_management/get_account_hierarchy.rb +2 -2
- data/examples/v201109/account_management/get_client_customer_id.rb +6 -8
- data/examples/v201109/account_management/get_client_unit_usage.rb +6 -7
- data/examples/v201109/basic_operations/add_ad_groups.rb +111 -0
- data/examples/v201109/basic_operations/add_campaigns.rb +125 -0
- data/examples/v201109/basic_operations/add_keywords.rb +16 -11
- data/examples/v201109/basic_operations/add_text_ads.rb +23 -19
- data/examples/v201109/basic_operations/delete_ad.rb +7 -7
- data/examples/v201109/basic_operations/delete_ad_group.rb +7 -7
- data/examples/v201109/basic_operations/delete_campaign.rb +7 -7
- data/examples/v201109/basic_operations/delete_keyword.rb +7 -7
- data/examples/v201109/basic_operations/get_ad_groups.rb +7 -7
- data/examples/v201109/basic_operations/get_campaigns.rb +3 -3
- data/examples/v201109/basic_operations/get_keywords.rb +7 -7
- data/examples/v201109/basic_operations/get_text_ads.rb +7 -7
- data/examples/v201109/basic_operations/pause_ad.rb +7 -7
- data/examples/v201109/basic_operations/update_ad_group.rb +6 -6
- data/examples/v201109/basic_operations/update_campaign.rb +6 -6
- data/examples/v201109/basic_operations/update_keyword.rb +7 -7
- data/examples/v201109/campaign_management/add_experiment.rb +14 -9
- data/examples/v201109/campaign_management/add_keywords_in_bulk.rb +5 -5
- data/examples/v201109/campaign_management/add_location_extension.rb +13 -7
- data/examples/v201109/campaign_management/add_location_extension_override.rb +7 -7
- data/examples/v201109/campaign_management/get_all_disapproved_ads.rb +6 -6
- data/examples/v201109/campaign_management/promote_experiment.rb +5 -6
- data/examples/v201109/campaign_management/set_ad_parameters.rb +8 -8
- data/examples/v201109/campaign_management/validate_text_ad.rb +7 -9
- data/examples/v201109/error_handling/handle_captcha_challenge.rb +3 -4
- data/examples/v201109/error_handling/handle_partial_failures.rb +5 -6
- data/examples/v201109/error_handling/handle_policy_violation_error.rb +5 -6
- data/examples/v201109/error_handling/handle_two_factor_authorization_error.rb +2 -2
- data/examples/v201109/misc/get_all_images_and_videos.rb +3 -3
- data/examples/v201109/misc/upload_image.rb +2 -2
- data/examples/v201109/misc/use_oauth.rb +3 -3
- data/examples/v201109/optimization/estimate_keyword_traffic.rb +2 -2
- data/examples/v201109/optimization/get_keyword_bid_simulations.rb +6 -7
- data/examples/v201109/optimization/get_keyword_ideas.rb +6 -7
- data/examples/v201109/optimization/get_placement_ideas.rb +6 -7
- data/examples/v201109/remarketing/add_audience.rb +5 -3
- data/examples/v201109/remarketing/add_conversion_tracker.rb +12 -3
- data/examples/v201109/reporting/download_criteria_report.rb +7 -8
- data/examples/v201109/reporting/download_defined_report.rb +6 -7
- data/examples/v201109/reporting/get_campaign_stats.rb +105 -0
- data/examples/v201109/reporting/get_defined_reports.rb +2 -2
- data/examples/v201109/reporting/get_report_fields.rb +6 -7
- data/examples/v201109/reporting/parallel_report_download.rb +8 -8
- data/examples/v201109/targeting/add_campaign_targeting_criteria.rb +5 -6
- data/examples/v201109/targeting/get_campaign_targeting_criteria.rb +7 -8
- data/examples/v201109/targeting/get_targetable_languages_and_carriers.rb +2 -2
- data/examples/v201109/targeting/lookup_location.rb +2 -2
- data/lib/adwords_api/version.rb +1 -1
- data/test/examples/v201109/test_account_management.rb +60 -0
- data/test/examples/v201109/test_basic_operations.rb +172 -0
- data/test/examples/v201109/test_campaign_management.rb +116 -0
- data/test/examples/v201109/test_error_handling.rb +63 -0
- data/test/examples/v201109/test_misc.rb +45 -0
- data/test/examples/v201109/test_optimization.rb +63 -0
- data/test/examples/v201109/test_remarketing.rb +39 -0
- data/test/examples/v201109/test_reporting.rb +89 -0
- data/test/examples/v201109/test_targeting.rb +60 -0
- data/test/examples/v201109/utils.rb +239 -0
- data/test/suite_exampletests.rb +31 -0
- metadata +18 -6
- data/examples/v201109/basic_operations/add_ad_group.rb +0 -89
- data/examples/v201109/basic_operations/add_campaign.rb +0 -99
data/ChangeLog
CHANGED
data/README
CHANGED
@@ -178,7 +178,8 @@ respond in gzipped format. All requests are sent uncompressed regardless.
|
|
178
178
|
to regenerate the stubs if needed
|
179
179
|
|
180
180
|
$ gem build google-adwords-api.gemspec
|
181
|
-
|
181
|
+
$ gem build google-adx-buyer-api.gemspec
|
182
|
+
to build the gems
|
182
183
|
|
183
184
|
$ rake test
|
184
185
|
to run unit tests on the library
|
@@ -26,8 +26,6 @@
|
|
26
26
|
require 'adwords_api'
|
27
27
|
require 'adwords_api/utils'
|
28
28
|
|
29
|
-
API_VERSION = :v201109
|
30
|
-
|
31
29
|
def create_account()
|
32
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
31
|
# when called without parameters.
|
@@ -59,6 +57,8 @@ def create_account()
|
|
59
57
|
end
|
60
58
|
|
61
59
|
if __FILE__ == $0
|
60
|
+
API_VERSION = :v201109
|
61
|
+
|
62
62
|
begin
|
63
63
|
create_account()
|
64
64
|
|
@@ -26,9 +26,6 @@
|
|
26
26
|
require 'adwords_api'
|
27
27
|
require 'adwords_api/utils'
|
28
28
|
|
29
|
-
API_VERSION = :v201109
|
30
|
-
PAGE_SIZE = 500
|
31
|
-
|
32
29
|
def get_account_alerts()
|
33
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
34
31
|
# when called without parameters.
|
@@ -90,6 +87,9 @@ def get_account_alerts()
|
|
90
87
|
end
|
91
88
|
|
92
89
|
if __FILE__ == $0
|
90
|
+
API_VERSION = :v201109
|
91
|
+
PAGE_SIZE = 500
|
92
|
+
|
93
93
|
begin
|
94
94
|
get_account_alerts()
|
95
95
|
|
@@ -27,8 +27,6 @@ require 'adwords_api'
|
|
27
27
|
require 'date'
|
28
28
|
require 'pp'
|
29
29
|
|
30
|
-
API_VERSION = :v201109
|
31
|
-
|
32
30
|
def get_account_changes()
|
33
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
34
32
|
# when called without parameters.
|
@@ -116,6 +114,8 @@ def get_account_changes()
|
|
116
114
|
end
|
117
115
|
|
118
116
|
if __FILE__ == $0
|
117
|
+
API_VERSION = :v201109
|
118
|
+
|
119
119
|
begin
|
120
120
|
get_account_changes()
|
121
121
|
|
@@ -26,8 +26,6 @@
|
|
26
26
|
require 'adwords_api'
|
27
27
|
require 'adwords_api/utils'
|
28
28
|
|
29
|
-
API_VERSION = :v201109
|
30
|
-
|
31
29
|
def get_account_hierarchy()
|
32
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
31
|
# when called without parameters.
|
@@ -72,6 +70,8 @@ def get_account_hierarchy()
|
|
72
70
|
end
|
73
71
|
|
74
72
|
if __FILE__ == $0
|
73
|
+
API_VERSION = :v201109
|
74
|
+
|
75
75
|
begin
|
76
76
|
get_account_hierarchy()
|
77
77
|
|
@@ -27,9 +27,7 @@
|
|
27
27
|
require 'adwords_api'
|
28
28
|
require 'adwords_api/utils'
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
def get_client_customer_id()
|
30
|
+
def get_client_customer_id(client_email)
|
33
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
34
32
|
# when called without parameters.
|
35
33
|
adwords = AdwordsApi::Api.new
|
@@ -40,11 +38,7 @@ def get_client_customer_id()
|
|
40
38
|
|
41
39
|
info_srv = adwords.service(:InfoService, API_VERSION)
|
42
40
|
|
43
|
-
# Email address to find ID for.
|
44
|
-
client_email = 'INSERT_EMAIL_ADDRESS_HERE'
|
45
|
-
|
46
41
|
today = Time.new.strftime('%Y%m%d')
|
47
|
-
|
48
42
|
selector = {
|
49
43
|
:client_emails => [client_email],
|
50
44
|
:api_usage_type => 'UNIT_COUNT_FOR_CLIENTS',
|
@@ -66,8 +60,12 @@ def get_client_customer_id()
|
|
66
60
|
end
|
67
61
|
|
68
62
|
if __FILE__ == $0
|
63
|
+
API_VERSION = :v201109
|
64
|
+
|
69
65
|
begin
|
70
|
-
|
66
|
+
# Email address to find ID for.
|
67
|
+
client_email = 'INSERT_EMAIL_ADDRESS_HERE'
|
68
|
+
get_client_customer_id(client_email)
|
71
69
|
|
72
70
|
# HTTP errors.
|
73
71
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def get_client_unit_usage()
|
28
|
+
def get_client_unit_usage(client_customer_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -38,9 +36,6 @@ def get_client_unit_usage()
|
|
38
36
|
|
39
37
|
info_srv = adwords.service(:InfoService, API_VERSION)
|
40
38
|
|
41
|
-
# Specify client customer ID for the account to get usage for.
|
42
|
-
client_customer_id = 'INSERT_CLIENT_CUSTOMER_ID_HERE'.to_i
|
43
|
-
|
44
39
|
start_date = Time.now.strftime('%Y%m01')
|
45
40
|
end_date = Time.now.strftime('%Y%m%d')
|
46
41
|
|
@@ -67,8 +62,12 @@ def get_client_unit_usage()
|
|
67
62
|
end
|
68
63
|
|
69
64
|
if __FILE__ == $0
|
65
|
+
API_VERSION = :v201109
|
66
|
+
|
70
67
|
begin
|
71
|
-
|
68
|
+
# Specify client customer ID for the account to get usage for.
|
69
|
+
client_customer_id = 'INSERT_CLIENT_CUSTOMER_ID_HERE'.to_i
|
70
|
+
get_client_unit_usage(client_customer_id)
|
72
71
|
|
73
72
|
# HTTP errors.
|
74
73
|
rescue AdsCommon::Errors::HttpError => e
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
+
#
|
8
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
+
# implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
# This example illustrates how to create ad groups. To get a list of existing
|
22
|
+
# campaigns run get_campaigns.rb.
|
23
|
+
#
|
24
|
+
# Tags: AdGroupService.mutate
|
25
|
+
|
26
|
+
require 'adwords_api'
|
27
|
+
|
28
|
+
def add_ad_groups(campaign_id)
|
29
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
+
# when called without parameters.
|
31
|
+
adwords = AdwordsApi::Api.new
|
32
|
+
|
33
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
+
# the configuration file or provide your own logger:
|
35
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
+
|
37
|
+
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
38
|
+
|
39
|
+
ad_groups = [
|
40
|
+
{:name => "Earth to Mars Cruises #%d" % (Time.new.to_f * 1000).to_i,
|
41
|
+
:status => 'ENABLED',
|
42
|
+
:campaign_id => campaign_id,
|
43
|
+
:bids => {
|
44
|
+
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
45
|
+
# being created. It's only necessary when you must provide an explicit
|
46
|
+
# type that the client library can't infer.
|
47
|
+
:xsi_type => 'ManualCPCAdGroupBids',
|
48
|
+
:keyword_max_cpc => {
|
49
|
+
:amount => {
|
50
|
+
:micro_amount => 10000000
|
51
|
+
}
|
52
|
+
},
|
53
|
+
# Optional field.
|
54
|
+
:keyword_content_max_cpc => {:amount => {:micro_amount => 2000000}}
|
55
|
+
}},
|
56
|
+
{:name => "Earth to Pluto Cruises #%d" % (Time.new.to_f * 1000).to_i,
|
57
|
+
:status => 'ENABLED',
|
58
|
+
:campaign_id => campaign_id,
|
59
|
+
:bids => {
|
60
|
+
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
61
|
+
# being created. It's only necessary when you must provide an explicit
|
62
|
+
# type that the client library can't infer.
|
63
|
+
:xsi_type => 'ManualCPCAdGroupBids',
|
64
|
+
:keyword_max_cpc => {
|
65
|
+
:amount => {
|
66
|
+
:micro_amount => 10000000
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}}
|
70
|
+
]
|
71
|
+
|
72
|
+
# Prepare operations for adding ad groups.
|
73
|
+
operations = ad_groups.map do |ad_group|
|
74
|
+
{:operator => 'ADD', :operand => ad_group}
|
75
|
+
end
|
76
|
+
|
77
|
+
# Add ad groups.
|
78
|
+
response = ad_group_srv.mutate(operations)
|
79
|
+
if response and response[:value]
|
80
|
+
response[:value].each do |ad_group|
|
81
|
+
puts "Ad group ID %d was successfully added." % ad_group[:id]
|
82
|
+
end
|
83
|
+
else
|
84
|
+
raise StandardError, 'No ad group was added'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
if __FILE__ == $0
|
89
|
+
API_VERSION = :v201109
|
90
|
+
|
91
|
+
begin
|
92
|
+
# Campaign ID to add ad group to.
|
93
|
+
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
94
|
+
add_ad_groups(campaign_id)
|
95
|
+
|
96
|
+
# HTTP errors.
|
97
|
+
rescue AdsCommon::Errors::HttpError => e
|
98
|
+
puts "HTTP Error: %s" % e
|
99
|
+
|
100
|
+
# API errors.
|
101
|
+
rescue AdwordsApi::Errors::ApiException => e
|
102
|
+
puts "Message: %s" % e.message
|
103
|
+
puts 'Errors:'
|
104
|
+
e.errors.each_with_index do |error, index|
|
105
|
+
puts "\tError [%d]:" % (index + 1)
|
106
|
+
error.each do |field, value|
|
107
|
+
puts "\t\t%s: %s" % [field, value]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
+
#
|
8
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
+
# implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
# This example illustrates how to create campaigns.
|
22
|
+
#
|
23
|
+
# Tags: CampaignService.mutate
|
24
|
+
|
25
|
+
require 'adwords_api'
|
26
|
+
require 'date'
|
27
|
+
|
28
|
+
def add_campaigns()
|
29
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
+
# when called without parameters.
|
31
|
+
adwords = AdwordsApi::Api.new
|
32
|
+
|
33
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
+
# the configuration file or provide your own logger:
|
35
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
+
|
37
|
+
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
38
|
+
|
39
|
+
campaigns = [
|
40
|
+
{:name => "Interplanetary Cruise #%d" % (Time.new.to_f * 1000).to_i,
|
41
|
+
:status => 'PAUSED',
|
42
|
+
:bidding_strategy => {
|
43
|
+
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
44
|
+
# being created. It's only necessary when you must provide an explicit
|
45
|
+
# type that the client library can't infer.
|
46
|
+
:xsi_type => 'ManualCPC'
|
47
|
+
},
|
48
|
+
:budget => {
|
49
|
+
:period => 'DAILY',
|
50
|
+
:amount => {:micro_amount => 50000000},
|
51
|
+
:delivery_method => 'STANDARD'
|
52
|
+
},
|
53
|
+
# Set the campaign network options to Search and Search Network.
|
54
|
+
:network_setting => {
|
55
|
+
:target_google_search => true,
|
56
|
+
:target_search_network => true,
|
57
|
+
:target_content_network => false,
|
58
|
+
:target_content_contextual => false
|
59
|
+
},
|
60
|
+
# Optional fields:
|
61
|
+
:start_date =>
|
62
|
+
DateTime.parse((Date.today + 1).to_s).strftime('%Y%m%d'),
|
63
|
+
:ad_serving_optimization_status => 'ROTATE',
|
64
|
+
:frequency_cap => {
|
65
|
+
:impressions => '5',
|
66
|
+
:time_unit => 'DAY',
|
67
|
+
:level => 'ADGROUP'
|
68
|
+
}},
|
69
|
+
{:name => "Interplanetary Cruise banner #%d" % (Time.new.to_f * 1000).to_i,
|
70
|
+
:status => 'PAUSED',
|
71
|
+
:bidding_strategy => {
|
72
|
+
:xsi_type => 'ManualCPM'
|
73
|
+
},
|
74
|
+
:budget => {
|
75
|
+
:period => 'DAILY',
|
76
|
+
:amount => {:micro_amount => 150000000},
|
77
|
+
:delivery_method => 'STANDARD'
|
78
|
+
},
|
79
|
+
:network_setting => {
|
80
|
+
:target_google_search => false,
|
81
|
+
:target_search_network => false,
|
82
|
+
:target_content_network => true,
|
83
|
+
:target_content_contextual => false
|
84
|
+
}}
|
85
|
+
]
|
86
|
+
|
87
|
+
# Prepare for adding campaign.
|
88
|
+
operations = campaigns.map do |campaign|
|
89
|
+
{:operator => 'ADD', :operand => campaign}
|
90
|
+
end
|
91
|
+
|
92
|
+
# Add campaign.
|
93
|
+
response = campaign_srv.mutate(operations)
|
94
|
+
if response and response[:value]
|
95
|
+
response[:value].each do |campaign|
|
96
|
+
puts "Campaign with name '%s' and ID %d was added." %
|
97
|
+
[campaign[:name], campaign[:id]]
|
98
|
+
end
|
99
|
+
else
|
100
|
+
raise new StandardError, 'No campaigns were added.'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
if __FILE__ == $0
|
105
|
+
API_VERSION = :v201109
|
106
|
+
|
107
|
+
begin
|
108
|
+
add_campaigns()
|
109
|
+
|
110
|
+
# HTTP errors.
|
111
|
+
rescue AdsCommon::Errors::HttpError => e
|
112
|
+
puts "HTTP Error: %s" % e
|
113
|
+
|
114
|
+
# API errors.
|
115
|
+
rescue AdwordsApi::Errors::ApiException => e
|
116
|
+
puts "Message: %s" % e.message
|
117
|
+
puts 'Errors:'
|
118
|
+
e.errors.each_with_index do |error, index|
|
119
|
+
puts "\tError [%d]:" % (index + 1)
|
120
|
+
error.each do |field, value|
|
121
|
+
puts "\t\t%s: %s" % [field, value]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -25,9 +25,7 @@
|
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def add_keywords()
|
28
|
+
def add_keywords(ad_group_id)
|
31
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
30
|
# when called without parameters.
|
33
31
|
adwords = AdwordsApi::Api.new
|
@@ -39,8 +37,6 @@ def add_keywords()
|
|
39
37
|
ad_group_criterion_srv =
|
40
38
|
adwords.service(:AdGroupCriterionService, API_VERSION)
|
41
39
|
|
42
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
43
|
-
|
44
40
|
# Create keywords.
|
45
41
|
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
46
42
|
# being created. It's only necessary when you must provide an explicit
|
@@ -51,7 +47,12 @@ def add_keywords()
|
|
51
47
|
:criterion => {
|
52
48
|
:xsi_type => 'Keyword',
|
53
49
|
:text => 'mars cruise',
|
54
|
-
:match_type => 'BROAD'
|
50
|
+
:match_type => 'BROAD'
|
51
|
+
},
|
52
|
+
# Optional fields:
|
53
|
+
:user_status => 'PAUSED',
|
54
|
+
:destination_url => 'http://example.com/mars'
|
55
|
+
},
|
55
56
|
{:xsi_type => 'BiddableAdGroupCriterion',
|
56
57
|
:ad_group_id => ad_group_id,
|
57
58
|
:criterion => {
|
@@ -65,25 +66,29 @@ def add_keywords()
|
|
65
66
|
{:operator => 'ADD', :operand => keyword}
|
66
67
|
end
|
67
68
|
|
68
|
-
# Add
|
69
|
+
# Add keywords.
|
69
70
|
response = ad_group_criterion_srv.mutate(operations)
|
70
71
|
if response and response[:value]
|
71
72
|
ad_group_criteria = response[:value]
|
72
|
-
puts "Added %d
|
73
|
+
puts "Added %d keywords to ad group ID %d:" %
|
73
74
|
[ad_group_criteria.length, ad_group_id]
|
74
75
|
ad_group_criteria.each do |ad_group_criterion|
|
75
|
-
puts "\
|
76
|
+
puts "\tKeyword ID is %d and type is '%s'" %
|
76
77
|
[ad_group_criterion[:criterion][:id],
|
77
78
|
ad_group_criterion[:criterion][:type]]
|
78
79
|
end
|
79
80
|
else
|
80
|
-
|
81
|
+
raise StandardError, 'No keywords were added.'
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
85
|
if __FILE__ == $0
|
86
|
+
API_VERSION = :v201109
|
87
|
+
|
85
88
|
begin
|
86
|
-
|
89
|
+
# Ad group ID to add keywords to.
|
90
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
91
|
+
add_keywords(ad_group_id)
|
87
92
|
|
88
93
|
# HTTP errors.
|
89
94
|
rescue AdsCommon::Errors::HttpError => e
|