google-adwords-api 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/ChangeLog +12 -0
- data/examples/v201406/advanced_operations/{add_places_location_extensions.rb → add_google_my_business_location_extensions.rb} +24 -15
- data/examples/v201409/advanced_operations/{add_places_location_extensions.rb → add_google_my_business_location_extensions.rb} +41 -16
- data/examples/v201409/advanced_operations/use_shared_bidding_strategy.rb +1 -13
- data/examples/v201409/basic_operations/add_campaigns.rb +0 -10
- data/examples/v201409/remarketing/add_audience.rb +0 -1
- data/examples/v201409/remarketing/add_rule_based_user_lists.rb +171 -0
- data/examples/v201409/shopping_campaigns/add_shopping_campaign.rb +0 -4
- data/lib/adwords_api/api_config.rb +0 -78
- data/lib/adwords_api/report_header_handler.rb +0 -4
- data/lib/adwords_api/report_utils.rb +0 -9
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_choices.rb +138 -0
- data/test/adwords_api/test_report_utils.rb +0 -27
- data/test/templates/v201406/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201406/misc_use_oauth2_jwt.def +1 -1
- data/test/templates/v201409/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201409/misc_use_oauth2_jwt.def +1 -1
- metadata +8 -149
- data/examples/v201402/account_management/create_account.rb +0 -95
- data/examples/v201402/account_management/get_account_alerts.rb +0 -122
- data/examples/v201402/account_management/get_account_changes.rb +0 -145
- data/examples/v201402/account_management/get_account_hierarchy.rb +0 -103
- data/examples/v201402/advanced_operations/add_ad_group_bid_modifier.rb +0 -105
- data/examples/v201402/advanced_operations/add_click_to_download_ad.rb +0 -137
- data/examples/v201402/advanced_operations/add_places_location_extensions.rb +0 -159
- data/examples/v201402/advanced_operations/add_site_links.rb +0 -306
- data/examples/v201402/advanced_operations/get_ad_group_bid_modifiers.rb +0 -106
- data/examples/v201402/advanced_operations/update_site_links.rb +0 -194
- data/examples/v201402/advanced_operations/upload_offline_conversions.rb +0 -117
- data/examples/v201402/advanced_operations/use_shared_bidding_strategy.rb +0 -163
- data/examples/v201402/basic_operations/add_ad_groups.rb +0 -142
- data/examples/v201402/basic_operations/add_campaigns.rb +0 -153
- data/examples/v201402/basic_operations/add_keywords.rb +0 -116
- data/examples/v201402/basic_operations/add_text_ads.rb +0 -113
- data/examples/v201402/basic_operations/delete_ad.rb +0 -93
- data/examples/v201402/basic_operations/delete_ad_group.rb +0 -89
- data/examples/v201402/basic_operations/delete_campaign.rb +0 -90
- data/examples/v201402/basic_operations/delete_keyword.rb +0 -98
- data/examples/v201402/basic_operations/get_ad_groups.rb +0 -106
- data/examples/v201402/basic_operations/get_campaigns.rb +0 -101
- data/examples/v201402/basic_operations/get_campaigns_with_awql.rb +0 -93
- data/examples/v201402/basic_operations/get_keywords.rb +0 -112
- data/examples/v201402/basic_operations/get_text_ads.rb +0 -114
- data/examples/v201402/basic_operations/pause_ad.rb +0 -92
- data/examples/v201402/basic_operations/update_ad_group.rb +0 -89
- data/examples/v201402/basic_operations/update_campaign.rb +0 -90
- data/examples/v201402/basic_operations/update_keyword.rb +0 -110
- data/examples/v201402/campaign_management/add_experiment.rb +0 -166
- data/examples/v201402/campaign_management/add_keywords_in_bulk.rb +0 -158
- data/examples/v201402/campaign_management/add_location_extension.rb +0 -125
- data/examples/v201402/campaign_management/get_all_disapproved_ads.rb +0 -101
- data/examples/v201402/campaign_management/get_all_disapproved_ads_with_awql.rb +0 -93
- data/examples/v201402/campaign_management/promote_experiment.rb +0 -85
- data/examples/v201402/campaign_management/set_ad_parameters.rb +0 -122
- data/examples/v201402/campaign_management/set_criterion_bid_modifier.rb +0 -108
- data/examples/v201402/campaign_management/validate_text_ad.rb +0 -114
- data/examples/v201402/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201402/error_handling/handle_partial_failures.rb +0 -134
- data/examples/v201402/error_handling/handle_policy_violation_error.rb +0 -145
- data/examples/v201402/error_handling/handle_two_factor_authorization_error.rb +0 -88
- data/examples/v201402/misc/create_ad_words_session_without_properties_file.rb +0 -94
- data/examples/v201402/misc/get_all_images_and_videos.rb +0 -108
- data/examples/v201402/misc/setup_oauth2.rb +0 -88
- data/examples/v201402/misc/upload_image.rb +0 -97
- data/examples/v201402/misc/use_oauth2_jwt.rb +0 -97
- data/examples/v201402/optimization/estimate_keyword_traffic.rb +0 -137
- data/examples/v201402/optimization/get_keyword_bid_simulations.rb +0 -100
- data/examples/v201402/optimization/get_keyword_ideas.rb +0 -130
- data/examples/v201402/optimization/get_placement_ideas.rb +0 -112
- data/examples/v201402/remarketing/add_audience.rb +0 -123
- data/examples/v201402/remarketing/add_conversion_tracker.rb +0 -105
- data/examples/v201402/reporting/download_criteria_report.rb +0 -87
- data/examples/v201402/reporting/download_criteria_report_with_awql.rb +0 -86
- data/examples/v201402/reporting/get_report_fields.rb +0 -79
- data/examples/v201402/reporting/parallel_report_download.rb +0 -171
- data/examples/v201402/shopping_campaigns/add_product_partition_tree.rb +0 -269
- data/examples/v201402/shopping_campaigns/add_product_scope.rb +0 -133
- data/examples/v201402/shopping_campaigns/add_shopping_campaign.rb +0 -135
- data/examples/v201402/shopping_campaigns/get_product_category_taxonomy.rb +0 -117
- data/examples/v201402/shopping_campaigns/set_product_sales_channel.rb +0 -98
- data/examples/v201402/targeting/add_campaign_targeting_criteria.rb +0 -157
- data/examples/v201402/targeting/add_demographic_targeting_criteria.rb +0 -116
- data/examples/v201402/targeting/get_campaign_targeting_criteria.rb +0 -110
- data/examples/v201402/targeting/get_targetable_languages_and_carriers.rb +0 -94
- data/examples/v201402/targeting/lookup_location.rb +0 -112
- data/lib/adwords_api/v201402/ad_group_ad_service.rb +0 -42
- data/lib/adwords_api/v201402/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/ad_group_bid_modifier_service.rb +0 -42
- data/lib/adwords_api/v201402/ad_group_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/ad_group_criterion_service.rb +0 -42
- data/lib/adwords_api/v201402/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/ad_group_feed_service.rb +0 -42
- data/lib/adwords_api/v201402/ad_group_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/ad_group_service.rb +0 -42
- data/lib/adwords_api/v201402/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/ad_param_service.rb +0 -38
- data/lib/adwords_api/v201402/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/adwords_user_list_service.rb +0 -38
- data/lib/adwords_api/v201402/adwords_user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/alert_service.rb +0 -34
- data/lib/adwords_api/v201402/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/bidding_strategy_service.rb +0 -42
- data/lib/adwords_api/v201402/bidding_strategy_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201402/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/budget_service.rb +0 -42
- data/lib/adwords_api/v201402/budget_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/campaign_ad_extension_service.rb +0 -38
- data/lib/adwords_api/v201402/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/campaign_criterion_service.rb +0 -42
- data/lib/adwords_api/v201402/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/campaign_feed_service.rb +0 -42
- data/lib/adwords_api/v201402/campaign_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/campaign_service.rb +0 -42
- data/lib/adwords_api/v201402/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/campaign_shared_set_service.rb +0 -38
- data/lib/adwords_api/v201402/campaign_shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201402/constant_data_service.rb +0 -66
- data/lib/adwords_api/v201402/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201402/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/customer_feed_service.rb +0 -42
- data/lib/adwords_api/v201402/customer_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/customer_service.rb +0 -38
- data/lib/adwords_api/v201402/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201402/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201402/data_service.rb +0 -46
- data/lib/adwords_api/v201402/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/experiment_service.rb +0 -38
- data/lib/adwords_api/v201402/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/feed_item_service.rb +0 -42
- data/lib/adwords_api/v201402/feed_item_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/feed_mapping_service.rb +0 -42
- data/lib/adwords_api/v201402/feed_mapping_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/feed_service.rb +0 -42
- data/lib/adwords_api/v201402/feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201402/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/location_criterion_service.rb +0 -38
- data/lib/adwords_api/v201402/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/managed_customer_service.rb +0 -50
- data/lib/adwords_api/v201402/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/media_service.rb +0 -42
- data/lib/adwords_api/v201402/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201402/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/offline_conversion_feed_service.rb +0 -34
- data/lib/adwords_api/v201402/offline_conversion_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/report_definition_service.rb +0 -34
- data/lib/adwords_api/v201402/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/shared_criterion_service.rb +0 -38
- data/lib/adwords_api/v201402/shared_criterion_service_registry.rb +0 -47
- data/lib/adwords_api/v201402/shared_set_service.rb +0 -38
- data/lib/adwords_api/v201402/shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201402/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201402/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201402/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201402/traffic_estimator_service_registry.rb +0 -46
- data/test/templates/v201402/basic_operations_get_campaigns.def +0 -114
- data/test/templates/v201402/misc_use_oauth2_jwt.def +0 -131
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
YTU0N2JkMzRmZjM1MmI4Nzc1ZTcyMTBjY2NjN2Y0ZTdhYjUzZjliNQ==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
NDM3YmM4YTJkYWUzYjk5NjQwYTE5OGQxZjUyYjc1OTIwMTAyMWIwYQ==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
MGNiMTBiNjlhMDZmZGQ5NmJjMjlmZWQ1NWViNmJlMjgzNWZjZjA1NGI1NjNh
|
|
10
|
+
OTMwYmZhZDVkOWI2YmRjZGJkNjAwY2M4MWQ4NmM1ZDgyMjAwYWY4YjE0MzAw
|
|
11
|
+
OWM0NjZjMmI0YTg2YzYwYWNmM2Q2YjNjYmE3YmYwZjMwMGU3Nzk=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
NzIwNzQ5ZjdmNjI0OGIxOTVhYzY0YTI3Zjk1YmFhNzBhY2M0ZDEzNWI4MmU0
|
|
14
|
+
MWIwMDFlYzc0ZTJlMDVkNDRhMzU5NDllOWY1M2U2M2Q4M2U3Y2MzYjNhODNi
|
|
15
|
+
N2I5ZjA5ZDY1NGZjMjU0YTRhMTQ0MGVlYjkyNTRmYTE4YmRiYjQ=
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
0.14.0:
|
|
2
|
+
- Removed deprecated API version v201402.
|
|
3
|
+
- Removed support for returnMoneyInMicros header.
|
|
4
|
+
- Reworked Places examples to reference Google My Business.
|
|
5
|
+
|
|
6
|
+
0.13.4:
|
|
7
|
+
- Added rule-based remarketing example.
|
|
8
|
+
- Require google-ads-common 0.9.6 or later from now on.
|
|
9
|
+
|
|
10
|
+
0.13.3:
|
|
11
|
+
- Fixing file permissions on gem.
|
|
12
|
+
|
|
1
13
|
0.13.2:
|
|
2
14
|
- Support and examples for v201409.
|
|
3
15
|
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example adds a feed that syncs feed items from a Google
|
|
22
|
-
# and associates the feed with a customer.
|
|
21
|
+
# This example adds a feed that syncs feed items from a Google My Business (GMB)
|
|
22
|
+
# account and associates the feed with a customer.
|
|
23
23
|
#
|
|
24
24
|
# Tags: CustomerFeedService.mutate, FeedService.mutate
|
|
25
25
|
|
|
26
26
|
require 'adwords_api'
|
|
27
27
|
require 'date'
|
|
28
28
|
|
|
29
|
-
def
|
|
29
|
+
def add_gmb_location_extensions(gmb_email_address, gmb_access_token)
|
|
30
30
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
31
31
|
# when called without parameters.
|
|
32
32
|
adwords = AdwordsApi::Api.new
|
|
@@ -38,30 +38,33 @@ def add_places_location_extensions(places_email_address, places_access_token)
|
|
|
38
38
|
feed_srv = adwords.service(:FeedService, API_VERSION)
|
|
39
39
|
customer_feed_srv = adwords.service(:CustomerFeedService, API_VERSION)
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
# Create a feed that will sync to the Google My Business account specified
|
|
42
|
+
# by gmb_email_address. Do not add FeedAttributes to this object, as AdWords
|
|
43
|
+
# will add them automatically because this will be a system generated feed.
|
|
44
|
+
gmb_feed = {
|
|
45
|
+
:name => "GMB feed #%d" % (Time.new.to_f * 1000).to_i,
|
|
43
46
|
:system_feed_generation_data => {
|
|
44
47
|
:xsi_type => 'PlacesLocationFeedData',
|
|
45
48
|
:o_auth_info => {
|
|
46
49
|
:http_method => 'GET',
|
|
47
|
-
:http_request_url => 'https://www.
|
|
48
|
-
:http_authorization_header => "Bearer %s" %
|
|
50
|
+
:http_request_url => 'https://www.googleapis.com/auth/adwords',
|
|
51
|
+
:http_authorization_header => "Bearer %s" % gmb_access_token
|
|
49
52
|
},
|
|
50
|
-
:email_address =>
|
|
53
|
+
:email_address => gmb_email_address
|
|
51
54
|
},
|
|
52
55
|
# Since this feed's feed items will be managed by AdWords, you must set
|
|
53
56
|
# its origin to ADWORDS.
|
|
54
57
|
:origin => 'ADWORDS'
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
gmb_operation = {
|
|
58
61
|
:operator => 'ADD',
|
|
59
|
-
:operand =>
|
|
62
|
+
:operand => gmb_feed
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
result = feed_srv.mutate([
|
|
65
|
+
result = feed_srv.mutate([gmb_operation])
|
|
63
66
|
added_feed = result[:value].first
|
|
64
|
-
puts "Added
|
|
67
|
+
puts "Added GMB feed with ID %d" % added_feed[:id]
|
|
65
68
|
|
|
66
69
|
# Add a CustomerFeed that associates the feed with this customer for the
|
|
67
70
|
# LOCATION placeholder type.
|
|
@@ -127,10 +130,16 @@ if __FILE__ == $0
|
|
|
127
130
|
MAX_CUSTOMER_FEED_ADD_ATTEMPTS = 10
|
|
128
131
|
|
|
129
132
|
begin
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
# The email address of the owner of the GMB account.
|
|
134
|
+
gmb_email_address = 'INSERT_GMB_EMAIL_ADDRESS_HERE'
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
# To obtain an access token for your GMB account, generate a refresh token
|
|
137
|
+
# as you did for AdWords, but make sure you are logged in as the same user
|
|
138
|
+
# as gmb_email_address above when you follow the link, then capture
|
|
139
|
+
# the generated access token.
|
|
140
|
+
gmb_access_token = 'INSERT_GMB_ACCESS_TOKEN_HERE'
|
|
141
|
+
|
|
142
|
+
add_gmb_location_extensions(gmb_email_address, gmb_access_token)
|
|
134
143
|
|
|
135
144
|
# Authorization error.
|
|
136
145
|
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
@@ -18,15 +18,16 @@
|
|
|
18
18
|
# See the License for the specific language governing permissions and
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
|
-
# This example adds a feed that syncs feed items from a Google
|
|
22
|
-
# and associates the feed with a customer.
|
|
21
|
+
# This example adds a feed that syncs feed items from a Google My Business (GMB)
|
|
22
|
+
# account and associates the feed with a customer.
|
|
23
23
|
#
|
|
24
24
|
# Tags: CustomerFeedService.mutate, FeedService.mutate
|
|
25
25
|
|
|
26
26
|
require 'adwords_api'
|
|
27
27
|
require 'date'
|
|
28
28
|
|
|
29
|
-
def
|
|
29
|
+
def add_gmb_location_extensions(gmb_email_address, gmb_access_token,
|
|
30
|
+
business_account_identifier)
|
|
30
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
31
32
|
# when called without parameters.
|
|
32
33
|
adwords = AdwordsApi::Api.new
|
|
@@ -38,30 +39,39 @@ def add_places_location_extensions(places_email_address, places_access_token)
|
|
|
38
39
|
feed_srv = adwords.service(:FeedService, API_VERSION)
|
|
39
40
|
customer_feed_srv = adwords.service(:CustomerFeedService, API_VERSION)
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
# Create a feed that will sync to the Google My Business account specified
|
|
43
|
+
# by gmb_email_address. Do not add FeedAttributes to this object, as AdWords
|
|
44
|
+
# will add them automatically because this will be a system generated feed.
|
|
45
|
+
gmb_feed = {
|
|
46
|
+
:name => "GMB feed #%d" % (Time.new.to_f * 1000).to_i,
|
|
43
47
|
:system_feed_generation_data => {
|
|
44
48
|
:xsi_type => 'PlacesLocationFeedData',
|
|
45
49
|
:o_auth_info => {
|
|
46
50
|
:http_method => 'GET',
|
|
47
|
-
:http_request_url => 'https://www.
|
|
48
|
-
:http_authorization_header => "Bearer %s" %
|
|
51
|
+
:http_request_url => 'https://www.googleapis.com/auth/adwords',
|
|
52
|
+
:http_authorization_header => "Bearer %s" % gmb_access_token
|
|
49
53
|
},
|
|
50
|
-
:email_address =>
|
|
54
|
+
:email_address => gmb_email_address
|
|
51
55
|
},
|
|
52
56
|
# Since this feed's feed items will be managed by AdWords, you must set
|
|
53
57
|
# its origin to ADWORDS.
|
|
54
58
|
:origin => 'ADWORDS'
|
|
55
59
|
}
|
|
60
|
+
# Only include the business_account_identifier if it's specified.
|
|
61
|
+
# A nil value will cause an invalid request.
|
|
62
|
+
unless business_account_identifier.nil?
|
|
63
|
+
gmb_feed[:system_feed_generation_data][:business_account_identifier] =
|
|
64
|
+
business_account_identifier
|
|
65
|
+
end
|
|
56
66
|
|
|
57
|
-
|
|
67
|
+
gmb_operation = {
|
|
58
68
|
:operator => 'ADD',
|
|
59
|
-
:operand =>
|
|
69
|
+
:operand => gmb_feed
|
|
60
70
|
}
|
|
61
71
|
|
|
62
|
-
result = feed_srv.mutate([
|
|
72
|
+
result = feed_srv.mutate([gmb_operation])
|
|
63
73
|
added_feed = result[:value].first
|
|
64
|
-
puts "Added
|
|
74
|
+
puts "Added GMB feed with ID %d" % added_feed[:id]
|
|
65
75
|
|
|
66
76
|
# Add a CustomerFeed that associates the feed with this customer for the
|
|
67
77
|
# LOCATION placeholder type.
|
|
@@ -127,10 +137,25 @@ if __FILE__ == $0
|
|
|
127
137
|
MAX_CUSTOMER_FEED_ADD_ATTEMPTS = 10
|
|
128
138
|
|
|
129
139
|
begin
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
# The email address of either an owner or a manager of the GMB account.
|
|
141
|
+
gmb_email_address = 'INSERT_GMB_EMAIL_ADDRESS_HERE'
|
|
142
|
+
|
|
143
|
+
# To obtain an access token for your GMB account, generate a refresh token
|
|
144
|
+
# as you did for AdWords, but make sure you are logged in as the same user
|
|
145
|
+
# as gmb_email_address above when you follow the link, then capture
|
|
146
|
+
# the generated access token
|
|
147
|
+
gmb_access_token = 'INSERT_GMB_OAUTH_ACCESS_TOKEN_HERE'
|
|
148
|
+
|
|
149
|
+
# If the gmb_email_address above is for a GMB manager instead of
|
|
150
|
+
# the GMB account owner, then set business_account_identifier to the
|
|
151
|
+
# +Page ID of a location for which the manager has access. See the
|
|
152
|
+
# location extensions guide at
|
|
153
|
+
# https://developers.google.com/adwords/api/docs/guides/feed-services-locations
|
|
154
|
+
# for details.
|
|
155
|
+
business_account_identifier = nil
|
|
156
|
+
|
|
157
|
+
add_gmb_location_extensions(gmb_email_address, gmb_access_token,
|
|
158
|
+
business_account_identifier)
|
|
134
159
|
|
|
135
160
|
# Authorization error.
|
|
136
161
|
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
@@ -85,13 +85,7 @@ def use_shared_bidding_strategy()
|
|
|
85
85
|
:target_google_search => true,
|
|
86
86
|
:target_search_network => true,
|
|
87
87
|
:target_content_network => true
|
|
88
|
-
}
|
|
89
|
-
:settings => [
|
|
90
|
-
{
|
|
91
|
-
:xsi_type => 'KeywordMatchSetting',
|
|
92
|
-
:opt_in => true
|
|
93
|
-
}
|
|
94
|
-
]
|
|
88
|
+
}
|
|
95
89
|
},
|
|
96
90
|
{
|
|
97
91
|
:name => "Interplanetary Cruise banner #%d" % (Time.new.to_f * 1000).to_i,
|
|
@@ -101,12 +95,6 @@ def use_shared_bidding_strategy()
|
|
|
101
95
|
},
|
|
102
96
|
:budget => {:budget_id => budget_id},
|
|
103
97
|
:advertising_channel_type => 'DISPLAY',
|
|
104
|
-
:settings => [
|
|
105
|
-
{
|
|
106
|
-
:xsi_type => 'KeywordMatchSetting',
|
|
107
|
-
:opt_in => true
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
98
|
:network_setting => {
|
|
111
99
|
:target_google_search => false,
|
|
112
100
|
:target_search_network => false,
|
|
@@ -75,10 +75,6 @@ def add_campaigns()
|
|
|
75
75
|
:xsi_type => 'GeoTargetTypeSetting',
|
|
76
76
|
:positive_geo_target_type => 'DONT_CARE',
|
|
77
77
|
:negative_geo_target_type => 'DONT_CARE'
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
:xsi_type => 'KeywordMatchSetting',
|
|
81
|
-
:opt_in => true
|
|
82
78
|
}
|
|
83
79
|
],
|
|
84
80
|
:frequency_cap => {
|
|
@@ -94,12 +90,6 @@ def add_campaigns()
|
|
|
94
90
|
:bidding_strategy_type => 'MANUAL_CPC'
|
|
95
91
|
},
|
|
96
92
|
:budget => {:budget_id => budget_id},
|
|
97
|
-
:settings => [
|
|
98
|
-
{
|
|
99
|
-
:xsi_type => 'KeywordMatchSetting',
|
|
100
|
-
:opt_in => true
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
93
|
:advertising_channel_type => 'DISPLAY'
|
|
104
94
|
}
|
|
105
95
|
]
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Encoding: utf-8
|
|
3
|
+
#
|
|
4
|
+
# Author:: api.mcloonan@gmail.com (Michael Cloonan)
|
|
5
|
+
#
|
|
6
|
+
# Copyright:: Copyright 2014, 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 adds two rule-based remarketing user lists: one with no site
|
|
22
|
+
# visit data restrictions, and another that will only include users who visit
|
|
23
|
+
# your site in the next six months.
|
|
24
|
+
#
|
|
25
|
+
# Tags: AdwordsUserListService.mutate
|
|
26
|
+
|
|
27
|
+
require 'adwords_api'
|
|
28
|
+
|
|
29
|
+
def add_rule_based_user_lists()
|
|
30
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
31
|
+
# when called without parameters.
|
|
32
|
+
adwords = AdwordsApi::Api.new
|
|
33
|
+
|
|
34
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
|
35
|
+
# the configuration file or provide your own logger:
|
|
36
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
|
37
|
+
|
|
38
|
+
user_list_srv = adwords.service(:AdwordsUserListService, API_VERSION)
|
|
39
|
+
|
|
40
|
+
# First rule item group - users who visited the checkout page and had more
|
|
41
|
+
# than one item in their shopping cart.
|
|
42
|
+
cart_rule_item = {
|
|
43
|
+
:xsi_type => 'StringRuleItem',
|
|
44
|
+
:key => {
|
|
45
|
+
:name => 'ecomm_pagetype'
|
|
46
|
+
},
|
|
47
|
+
:op => 'EQUALS',
|
|
48
|
+
:value => 'checkout'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
cart_size_rule_item = {
|
|
52
|
+
:xsi_type => 'NumberRuleItem',
|
|
53
|
+
:key => {
|
|
54
|
+
:name => 'cartsize'
|
|
55
|
+
},
|
|
56
|
+
:op => 'GREATER_THAN',
|
|
57
|
+
:value => 1.0
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Combine the two rule items into a RuleItemGroup so AdWords will AND
|
|
61
|
+
# their rules together.
|
|
62
|
+
checkout_multiple_item_group = {
|
|
63
|
+
:items => [cart_rule_item, cart_size_rule_item]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# Second rule item group - users who checked out after October 31st
|
|
67
|
+
# and before January 1st.
|
|
68
|
+
start_date_rule_item = {
|
|
69
|
+
:xsi_type => 'DateRuleItem',
|
|
70
|
+
:key => {
|
|
71
|
+
:name => 'checkoutdate'
|
|
72
|
+
},
|
|
73
|
+
:op => 'AFTER',
|
|
74
|
+
:value => '20141031'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
end_date_rule_item = {
|
|
78
|
+
:xsi_type => 'DateRuleItem',
|
|
79
|
+
:key => {
|
|
80
|
+
:name => 'checkoutdate'
|
|
81
|
+
},
|
|
82
|
+
:op => 'BEFORE',
|
|
83
|
+
:value => '20150101'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# Combine the date rule items into a RuleItemGroup.
|
|
87
|
+
checked_out_nov_dec_item_group = {
|
|
88
|
+
:items => [start_date_rule_item, end_date_rule_item]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Combine the rule item groups into a Rule so AdWords will OR the
|
|
92
|
+
# groups together.
|
|
93
|
+
rule = {
|
|
94
|
+
:groups => [checkout_multiple_item_group, checked_out_nov_dec_item_group]
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# Create the user list with no restrictions on site visit date.
|
|
98
|
+
expression_user_list = {
|
|
99
|
+
:xsi_type => 'ExpressionRuleUserList',
|
|
100
|
+
:name => 'Users who checked out in November or December OR ' +
|
|
101
|
+
'visited the checkout page with more than one item in their cart',
|
|
102
|
+
:description => 'Expression based user list',
|
|
103
|
+
:rule => rule
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Create the user list restricted to users who visit your site within the
|
|
107
|
+
# specified timeframe.
|
|
108
|
+
date_user_list = {
|
|
109
|
+
:xsi_type => 'DateSpecificRuleUserList',
|
|
110
|
+
:name => 'Date rule user list created at ' + Time.now.to_s,
|
|
111
|
+
:description => 'Users who visited the site between 20141031 and ' +
|
|
112
|
+
'20150331 and checked out in November or December OR visited the ' +
|
|
113
|
+
'checkout page with more than one item in their cart',
|
|
114
|
+
# We re-use the rule here. To avoid side effects, we need a deep copy.
|
|
115
|
+
:rule => Marshal.load(Marshal.dump(rule)),
|
|
116
|
+
# Set the start and end dates of the user list.
|
|
117
|
+
:start_date => '20141031',
|
|
118
|
+
:end_date => '20150331'
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# Create operations to add the user lists.
|
|
122
|
+
operations = [expression_user_list, date_user_list].map do |user_list|
|
|
123
|
+
{
|
|
124
|
+
:operand => user_list,
|
|
125
|
+
:operator => 'ADD'
|
|
126
|
+
}
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Submit the operations.
|
|
130
|
+
response = user_list_srv.mutate(operations)
|
|
131
|
+
|
|
132
|
+
# Display the results.
|
|
133
|
+
response[:value].each do |user_list|
|
|
134
|
+
puts ("User list added with ID %d, name '%s', status '%s', " +
|
|
135
|
+
"list type '%s', accountUserListStatus '%s', description '%s'.") %
|
|
136
|
+
[user_list[:id], user_list[:name], user_list[:status],
|
|
137
|
+
user_list[:list_type], user_list[:account_user_list_status],
|
|
138
|
+
user_list[:description]]
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
if __FILE__ == $0
|
|
143
|
+
API_VERSION = :v201409
|
|
144
|
+
|
|
145
|
+
begin
|
|
146
|
+
add_rule_based_user_lists()
|
|
147
|
+
|
|
148
|
+
# Authorization error.
|
|
149
|
+
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
150
|
+
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
|
151
|
+
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
|
152
|
+
"to retrieve and store OAuth2 tokens."
|
|
153
|
+
puts "See this wiki page for more details:\n\n " +
|
|
154
|
+
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
|
155
|
+
|
|
156
|
+
# HTTP errors.
|
|
157
|
+
rescue AdsCommon::Errors::HttpError => e
|
|
158
|
+
puts "HTTP Error: %s" % e
|
|
159
|
+
|
|
160
|
+
# API errors.
|
|
161
|
+
rescue AdwordsApi::Errors::ApiException => e
|
|
162
|
+
puts "Message: %s" % e.message
|
|
163
|
+
puts 'Errors:'
|
|
164
|
+
e.errors.each_with_index do |error, index|
|
|
165
|
+
puts "\tError [%d]:" % (index + 1)
|
|
166
|
+
error.each do |field, value|
|
|
167
|
+
puts "\t\t%s: %s" % [field, value]
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|