google-adwords-api 0.14.2 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/ChangeLog +7 -0
- data/README.md +3 -3
- data/adwords_api.yml +5 -0
- data/examples/v201409/account_management/get_account_hierarchy.rb +2 -2
- data/examples/v201409/advanced_operations/{add_ad_customizer.rb → add_ad_customizers.rb} +4 -4
- data/examples/v201409/extensions/add_site_links_using_feeds.rb +12 -12
- data/examples/v201409/migration/migrate_to_extension_settings.rb +29 -2
- data/examples/v201409/reporting/parallel_report_download.rb +1 -1
- data/examples/v201502/advanced_operations/{add_ad_customizer.rb → add_ad_customizers.rb} +37 -125
- data/examples/v201502/extensions/add_site_links_using_feeds.rb +22 -52
- data/examples/v201502/migration/migrate_to_extension_settings.rb +29 -2
- data/lib/adwords_api.rb +9 -29
- data/lib/adwords_api/api_config.rb +0 -80
- data/lib/adwords_api/credential_handler.rb +8 -9
- data/lib/adwords_api/report_header_handler.rb +6 -2
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_adwords_api.rb +0 -9
- data/test/adwords_api/test_api_config.rb +8 -8
- data/test/adwords_api/test_credential_handler.rb +17 -0
- data/test/adwords_api/test_report_utils.rb +1 -1
- data/test/templates/v201409/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201409/misc_use_oauth2_jwt.def +1 -1
- data/test/templates/v201502/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201502/misc_use_oauth2_jwt.def +1 -1
- metadata +4 -153
- data/examples/v201406/account_management/create_account.rb +0 -92
- data/examples/v201406/account_management/get_account_alerts.rb +0 -122
- data/examples/v201406/account_management/get_account_changes.rb +0 -145
- data/examples/v201406/account_management/get_account_hierarchy.rb +0 -103
- data/examples/v201406/advanced_operations/add_ad_customizer.rb +0 -277
- data/examples/v201406/advanced_operations/add_ad_group_bid_modifier.rb +0 -105
- data/examples/v201406/advanced_operations/add_click_to_download_ad.rb +0 -137
- data/examples/v201406/advanced_operations/add_google_my_business_location_extensions.rb +0 -167
- data/examples/v201406/advanced_operations/add_site_links.rb +0 -306
- data/examples/v201406/advanced_operations/add_text_ad_with_upgraded_urls.rb +0 -137
- data/examples/v201406/advanced_operations/get_ad_group_bid_modifiers.rb +0 -106
- data/examples/v201406/advanced_operations/upload_offline_conversions.rb +0 -117
- data/examples/v201406/advanced_operations/use_shared_bidding_strategy.rb +0 -164
- data/examples/v201406/basic_operations/add_ad_groups.rb +0 -144
- data/examples/v201406/basic_operations/add_campaigns.rb +0 -153
- data/examples/v201406/basic_operations/add_keywords.rb +0 -116
- data/examples/v201406/basic_operations/add_text_ads.rb +0 -113
- data/examples/v201406/basic_operations/get_ad_groups.rb +0 -106
- data/examples/v201406/basic_operations/get_campaigns.rb +0 -101
- data/examples/v201406/basic_operations/get_campaigns_with_awql.rb +0 -93
- data/examples/v201406/basic_operations/get_keywords.rb +0 -112
- data/examples/v201406/basic_operations/get_text_ads.rb +0 -114
- data/examples/v201406/basic_operations/pause_ad.rb +0 -92
- data/examples/v201406/basic_operations/remove_ad.rb +0 -93
- data/examples/v201406/basic_operations/remove_ad_group.rb +0 -89
- data/examples/v201406/basic_operations/remove_campaign.rb +0 -91
- data/examples/v201406/basic_operations/remove_keyword.rb +0 -98
- data/examples/v201406/basic_operations/update_ad_group.rb +0 -89
- data/examples/v201406/basic_operations/update_campaign.rb +0 -90
- data/examples/v201406/basic_operations/update_keyword.rb +0 -110
- data/examples/v201406/campaign_management/add_campaign_labels.rb +0 -86
- data/examples/v201406/campaign_management/add_experiment.rb +0 -166
- data/examples/v201406/campaign_management/add_keywords_in_bulk.rb +0 -158
- data/examples/v201406/campaign_management/add_location_extension.rb +0 -125
- data/examples/v201406/campaign_management/get_all_disapproved_ads.rb +0 -101
- data/examples/v201406/campaign_management/get_all_disapproved_ads_with_awql.rb +0 -93
- data/examples/v201406/campaign_management/get_campaigns_by_label.rb +0 -112
- data/examples/v201406/campaign_management/promote_experiment.rb +0 -85
- data/examples/v201406/campaign_management/set_ad_parameters.rb +0 -122
- data/examples/v201406/campaign_management/set_criterion_bid_modifier.rb +0 -108
- data/examples/v201406/campaign_management/validate_text_ad.rb +0 -114
- data/examples/v201406/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201406/error_handling/handle_partial_failures.rb +0 -134
- data/examples/v201406/error_handling/handle_policy_violation_error.rb +0 -145
- data/examples/v201406/error_handling/handle_two_factor_authorization_error.rb +0 -88
- data/examples/v201406/misc/create_ad_words_session_without_properties_file.rb +0 -94
- data/examples/v201406/misc/get_all_images_and_videos.rb +0 -108
- data/examples/v201406/misc/setup_oauth2.rb +0 -88
- data/examples/v201406/misc/upload_image.rb +0 -97
- data/examples/v201406/misc/use_oauth2_jwt.rb +0 -97
- data/examples/v201406/optimization/estimate_keyword_traffic.rb +0 -155
- data/examples/v201406/optimization/get_keyword_bid_simulations.rb +0 -100
- data/examples/v201406/optimization/get_keyword_ideas.rb +0 -130
- data/examples/v201406/optimization/get_placement_ideas.rb +0 -112
- data/examples/v201406/remarketing/add_audience.rb +0 -123
- data/examples/v201406/remarketing/add_conversion_tracker.rb +0 -105
- data/examples/v201406/reporting/download_criteria_report.rb +0 -87
- data/examples/v201406/reporting/download_criteria_report_with_awql.rb +0 -86
- data/examples/v201406/reporting/get_report_fields.rb +0 -79
- data/examples/v201406/reporting/parallel_report_download.rb +0 -171
- data/examples/v201406/shopping_campaigns/add_product_partition_tree.rb +0 -269
- data/examples/v201406/shopping_campaigns/add_product_scope.rb +0 -133
- data/examples/v201406/shopping_campaigns/add_shopping_campaign.rb +0 -135
- data/examples/v201406/shopping_campaigns/get_product_category_taxonomy.rb +0 -117
- data/examples/v201406/shopping_campaigns/set_product_sales_channel.rb +0 -98
- data/examples/v201406/targeting/add_campaign_targeting_criteria.rb +0 -173
- data/examples/v201406/targeting/add_demographic_targeting_criteria.rb +0 -116
- data/examples/v201406/targeting/get_campaign_targeting_criteria.rb +0 -110
- data/examples/v201406/targeting/get_targetable_languages_and_carriers.rb +0 -94
- data/examples/v201406/targeting/lookup_location.rb +0 -112
- data/examples/v201502/campaign_management/add_location_extension.rb +0 -125
- data/lib/adwords_api/v201406/ad_group_ad_service.rb +0 -46
- data/lib/adwords_api/v201406/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/ad_group_bid_modifier_service.rb +0 -42
- data/lib/adwords_api/v201406/ad_group_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/ad_group_criterion_service.rb +0 -46
- data/lib/adwords_api/v201406/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/ad_group_feed_service.rb +0 -42
- data/lib/adwords_api/v201406/ad_group_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/ad_group_service.rb +0 -46
- data/lib/adwords_api/v201406/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/ad_param_service.rb +0 -38
- data/lib/adwords_api/v201406/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/adwords_user_list_service.rb +0 -38
- data/lib/adwords_api/v201406/adwords_user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/alert_service.rb +0 -34
- data/lib/adwords_api/v201406/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/bidding_strategy_service.rb +0 -42
- data/lib/adwords_api/v201406/bidding_strategy_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201406/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/budget_service.rb +0 -42
- data/lib/adwords_api/v201406/budget_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/campaign_ad_extension_service.rb +0 -38
- data/lib/adwords_api/v201406/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/campaign_criterion_service.rb +0 -42
- data/lib/adwords_api/v201406/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/campaign_feed_service.rb +0 -42
- data/lib/adwords_api/v201406/campaign_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/campaign_service.rb +0 -46
- data/lib/adwords_api/v201406/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/campaign_shared_set_service.rb +0 -38
- data/lib/adwords_api/v201406/campaign_shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201406/constant_data_service.rb +0 -66
- data/lib/adwords_api/v201406/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201406/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/customer_feed_service.rb +0 -42
- data/lib/adwords_api/v201406/customer_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/customer_service.rb +0 -38
- data/lib/adwords_api/v201406/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201406/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201406/data_service.rb +0 -54
- data/lib/adwords_api/v201406/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/experiment_service.rb +0 -38
- data/lib/adwords_api/v201406/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/feed_item_service.rb +0 -42
- data/lib/adwords_api/v201406/feed_item_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/feed_mapping_service.rb +0 -42
- data/lib/adwords_api/v201406/feed_mapping_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/feed_service.rb +0 -42
- data/lib/adwords_api/v201406/feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201406/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/label_service.rb +0 -42
- data/lib/adwords_api/v201406/label_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/location_criterion_service.rb +0 -38
- data/lib/adwords_api/v201406/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/managed_customer_service.rb +0 -50
- data/lib/adwords_api/v201406/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/media_service.rb +0 -42
- data/lib/adwords_api/v201406/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201406/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/offline_conversion_feed_service.rb +0 -34
- data/lib/adwords_api/v201406/offline_conversion_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/report_definition_service.rb +0 -34
- data/lib/adwords_api/v201406/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/shared_criterion_service.rb +0 -38
- data/lib/adwords_api/v201406/shared_criterion_service_registry.rb +0 -47
- data/lib/adwords_api/v201406/shared_set_service.rb +0 -38
- data/lib/adwords_api/v201406/shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201406/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201406/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201406/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201406/traffic_estimator_service_registry.rb +0 -46
- data/test/templates/v201406/basic_operations_get_campaigns.def +0 -114
- data/test/templates/v201406/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
|
+
N2IwZjhmNzIxODY2YjM2YzgyY2NiNWVmNWM1OGNmODQwNTBlNzEyNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjkyNDVkMTVjZTg1MWZmZmFjYTI2ZjExMjQ0ZjAzOTgyYzU3ZmZlYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmNiODQ0MzNjMDJlZjZjMTNlYWZiZWMzYWVmN2ZmMjJkZmE3Y2IzNTM2NzE2
|
10
|
+
MzZkMWNjNDJiNDAxNTFhZTNjNjNjNTkxZDZlODg5NWQ2N2E1MzM4YzJmNmY1
|
11
|
+
MTNlNWMxZjhiNGE3NTYzNWRmOTExNzVlZWJmZmU4OTY4ZTkxZWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTU0NTgxMDhjNTNjOTA0MDEyZTJjZGFlMDU2OWRhNDYwOWRlYzA4YzMyZGMx
|
14
|
+
MGIwYjFkMTFiZWY3MGE3YzcxNDk2ZDZhZjcyYzE0ZGIyMDE4YTkxMzkzMjE1
|
15
|
+
NDhmMDA4M2UwNDI1YWJlNWY5N2Y3NWNiOGUwYjAzYjI2Nzc0NmQ=
|
data/ChangeLog
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
+
0.15.0:
|
2
|
+
- Removed deprecated API version v201406.
|
3
|
+
- Updated Feeds migration example to account for platform restrictions.
|
4
|
+
- Added support for skipping column header option in reporting.
|
5
|
+
- Reworked add sitelinks example for final URLs and functionString.
|
6
|
+
|
1
7
|
0.14.2:
|
2
8
|
- Support and examples for v201502.
|
9
|
+
- Added support for skipping report header and summary options.
|
3
10
|
|
4
11
|
0.14.1:
|
5
12
|
- Corrected the comments and settings regarding target_all in add_ad_groups
|
data/README.md
CHANGED
@@ -74,7 +74,7 @@ The basics of making a request are:
|
|
74
74
|
|
75
75
|
3. Specify which service you're looking to use, and which version:
|
76
76
|
|
77
|
-
campaign_srv = adwords.service(:CampaignService, :
|
77
|
+
campaign_srv = adwords.service(:CampaignService, :v201502)
|
78
78
|
|
79
79
|
4. You should now be able to just use the API methods in the returned object:
|
80
80
|
|
@@ -211,7 +211,7 @@ To target a specific version:
|
|
211
211
|
|
212
212
|
For example:
|
213
213
|
|
214
|
-
$ rake generate[
|
214
|
+
$ rake generate[v201502]
|
215
215
|
|
216
216
|
To target a specific service in a specific version:
|
217
217
|
|
@@ -219,7 +219,7 @@ To target a specific service in a specific version:
|
|
219
219
|
|
220
220
|
For example:
|
221
221
|
|
222
|
-
$ rake generate[
|
222
|
+
$ rake generate[v201502,CampaignService]
|
223
223
|
|
224
224
|
To build the gems:
|
225
225
|
|
data/adwords_api.yml
CHANGED
@@ -41,4 +41,9 @@
|
|
41
41
|
# the URL, e.g.: http://user:password@proxy_hostname:8080
|
42
42
|
# :proxy: INSERT_PROXY_HERE
|
43
43
|
:library:
|
44
|
+
# Optional: set the log level.
|
44
45
|
:log_level: INFO
|
46
|
+
# Optional: uncomment to skip header / summary rows in reporting.
|
47
|
+
#:skip_report_header: true
|
48
|
+
#:skip_report_summary: true
|
49
|
+
#:skip_column_header: true
|
@@ -45,8 +45,8 @@ def get_account_hierarchy()
|
|
45
45
|
:fields => ['CustomerId', 'Name']
|
46
46
|
}
|
47
47
|
|
48
|
-
# Run the request
|
49
|
-
graph =
|
48
|
+
# Run the request. Make sure the configured clientCustomerId is an MCC.
|
49
|
+
graph = managed_customer_srv.get(selector)
|
50
50
|
|
51
51
|
if graph and graph[:entries]
|
52
52
|
puts 'Accounts under this hierarchy: %d' % graph[:total_num_entries]
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# Author:: api.mcloonan@gmail.com (Michael Cloonan)
|
5
5
|
#
|
6
|
-
# Copyright:: Copyright
|
6
|
+
# Copyright:: Copyright 2015, Google Inc. All Rights Reserved.
|
7
7
|
#
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
9
|
# you may not use this file except in compliance with the License.
|
@@ -27,7 +27,7 @@
|
|
27
27
|
|
28
28
|
require 'adwords_api'
|
29
29
|
|
30
|
-
def
|
30
|
+
def add_ad_customizers(ad_group_ids)
|
31
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
32
|
# when called without parameters.
|
33
33
|
adwords = AdwordsApi::Api.new
|
@@ -214,7 +214,7 @@ def add_ad_customizer(ad_group_ids)
|
|
214
214
|
:operator => 'ADD',
|
215
215
|
:operand => {
|
216
216
|
:ad_group_id => ad_group_id,
|
217
|
-
:ad => text_ad
|
217
|
+
:ad => text_ad.dup()
|
218
218
|
}
|
219
219
|
}
|
220
220
|
end
|
@@ -249,7 +249,7 @@ if __FILE__ == $0
|
|
249
249
|
'INSERT_AD_GROUP_ID_HERE'.to_i,
|
250
250
|
'INSERT_AD_GROUP_ID_HERE'.to_i
|
251
251
|
]
|
252
|
-
|
252
|
+
add_ad_customizers(ad_group_ids)
|
253
253
|
|
254
254
|
# Authorization error.
|
255
255
|
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
@@ -46,7 +46,7 @@ def add_site_links(campaign_id)
|
|
46
46
|
:name => 'Feed For Site Links',
|
47
47
|
:attributes => [
|
48
48
|
{:type => 'STRING', :name => 'Link Text'},
|
49
|
-
{:type => '
|
49
|
+
{:type => 'URL_LIST', :name => 'Final URLs'},
|
50
50
|
{:type => 'STRING', :name => 'Line 1 Description'},
|
51
51
|
{:type => 'STRING', :name => 'Line 2 Description'}
|
52
52
|
]
|
@@ -59,7 +59,7 @@ def add_site_links(campaign_id)
|
|
59
59
|
feed = response[:value].first
|
60
60
|
# Attribute of type STRING.
|
61
61
|
link_text_feed_attribute_id = feed[:attributes][0][:id]
|
62
|
-
# Attribute of type
|
62
|
+
# Attribute of type URL_LIST.
|
63
63
|
final_url_feed_attribute_id = feed[:attributes][1][:id]
|
64
64
|
# Attribute of type STRING.
|
65
65
|
line_1_feed_attribute_id = feed[:attributes][2][:id]
|
@@ -67,7 +67,7 @@ def add_site_links(campaign_id)
|
|
67
67
|
line_2_feed_attribute_id = feed[:attributes][3][:id]
|
68
68
|
puts "Feed with name '%s' and ID %d was added with" %
|
69
69
|
[feed[:name], feed[:id]]
|
70
|
-
puts "\tText attribute ID %d and Final
|
70
|
+
puts "\tText attribute ID %d and Final URLs attribute ID %d " +
|
71
71
|
"and Line 1 attribute ID %d and Line 2 attribute ID %d." % [
|
72
72
|
link_text_feed_attribute_id,
|
73
73
|
final_url_feed_attribute_id,
|
@@ -88,37 +88,37 @@ def add_site_links(campaign_id)
|
|
88
88
|
items_data = [
|
89
89
|
{
|
90
90
|
:text => 'Home',
|
91
|
-
:
|
91
|
+
:final_urls => ['http://www.example.com'],
|
92
92
|
:line_1 => 'Home line 1',
|
93
93
|
:line_2 => 'Home line 2'
|
94
94
|
},
|
95
95
|
{
|
96
96
|
:text => 'Stores',
|
97
|
-
:
|
97
|
+
:final_urls => ['http://www.example.com/stores'],
|
98
98
|
:line_1 => 'Stores line 1',
|
99
99
|
:line_2 => 'Stores line 2'
|
100
100
|
},
|
101
101
|
{
|
102
102
|
:text => 'On Sale',
|
103
|
-
:
|
103
|
+
:final_urls => ['http://www.example.com/sale'],
|
104
104
|
:line_1 => 'On Sale line 1',
|
105
105
|
:line_2 => 'On Sale line 2'
|
106
106
|
},
|
107
107
|
{
|
108
108
|
:text => 'Support',
|
109
|
-
:
|
109
|
+
:final_urls => ['http://www.example.com/support'],
|
110
110
|
:line_1 => 'Support line 1',
|
111
111
|
:line_2 => 'Support line 2'
|
112
112
|
},
|
113
113
|
{
|
114
114
|
:text => 'Products',
|
115
|
-
:
|
115
|
+
:final_urls => ['http://www.example.com/products'],
|
116
116
|
:line_1 => 'Products line 1',
|
117
117
|
:line_2 => 'Products line 2'
|
118
118
|
},
|
119
119
|
{
|
120
120
|
:text => 'About',
|
121
|
-
:
|
121
|
+
:final_urls => ['http://www.example.com/about'],
|
122
122
|
:line_1 => 'About line 1',
|
123
123
|
:line_2 => 'About line 2'
|
124
124
|
}
|
@@ -134,7 +134,7 @@ def add_site_links(campaign_id)
|
|
134
134
|
},
|
135
135
|
{
|
136
136
|
:feed_attribute_id => sitelinks_data[:final_url_feed_id],
|
137
|
-
:
|
137
|
+
:string_values => item[:final_urls]
|
138
138
|
},
|
139
139
|
{
|
140
140
|
:feed_attribute_id => sitelinks_data[:line_1_feed_id],
|
@@ -174,7 +174,7 @@ def add_site_links(campaign_id)
|
|
174
174
|
},
|
175
175
|
{
|
176
176
|
:feed_attribute_id => sitelinks_data[:final_url_feed_id],
|
177
|
-
:field_id =>
|
177
|
+
:field_id => PLACEHOLDER_FIELD_SITELINK_FINAL_URLS
|
178
178
|
},
|
179
179
|
{
|
180
180
|
:feed_attribute_id => sitelinks_data[:line_1_feed_id],
|
@@ -271,7 +271,7 @@ if __FILE__ == $0
|
|
271
271
|
# https://developers.google.com/adwords/api/docs/appendix/placeholders
|
272
272
|
PLACEHOLDER_SITELINKS = 1
|
273
273
|
PLACEHOLDER_FIELD_SITELINK_LINK_TEXT = 1
|
274
|
-
|
274
|
+
PLACEHOLDER_FIELD_SITELINK_FINAL_URLS = 5
|
275
275
|
PLACEHOLDER_FIELD_SITELINK_LINE_1_TEXT = 3
|
276
276
|
PLACEHOLDER_FIELD_SITELINK_LINE_2_TEXT = 4
|
277
277
|
|
@@ -64,13 +64,15 @@ def migrate_to_extension_settings()
|
|
64
64
|
next
|
65
65
|
end
|
66
66
|
|
67
|
+
platform_restrictions = get_platform_restrictions(campaign_feed)
|
68
|
+
|
67
69
|
# Delete the campaign feed that associates the sitelinks from the
|
68
70
|
# feed to the campaign.
|
69
71
|
delete_campaign_feed(adwords, campaign_feed)
|
70
72
|
|
71
73
|
# Create extension settings instead of sitelinks.
|
72
74
|
create_extension_setting(adwords, feed_items, campaign_feed,
|
73
|
-
feed_item_ids)
|
75
|
+
feed_item_ids, platform_restrictions)
|
74
76
|
|
75
77
|
# Mark the sitelinks from the feed for deletion.
|
76
78
|
feed_item_ids
|
@@ -201,6 +203,26 @@ def get_feed_items(adwords, feed)
|
|
201
203
|
return feed_items
|
202
204
|
end
|
203
205
|
|
206
|
+
def get_platform_restrictions(campaign_feed)
|
207
|
+
platform_restrictions = nil
|
208
|
+
|
209
|
+
if campaign_feed[:matching_function][:operator] == 'AND'
|
210
|
+
campaign_feed[:matching_function][:lhs_operand].each do |argument|
|
211
|
+
# Check if matchingFunction is EQUALS(CONTEXT.DEVICE, 'Mobile')
|
212
|
+
if argument[:value][:operator] == 'EQUALS'
|
213
|
+
request_context_operand = argument[:value][:lhs_operand].first()
|
214
|
+
if request_context_operand &&
|
215
|
+
request_context_operand == 'DEVICE_PLATFORM'
|
216
|
+
platform_restrictions =
|
217
|
+
argument[:value][:rhs_operand].first().upcase()
|
218
|
+
break
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
return platform_restrictions
|
224
|
+
end
|
225
|
+
|
204
226
|
def delete_old_feed_items(adwords, feed_item_ids, feed)
|
205
227
|
return if feed_item_ids.empty?
|
206
228
|
|
@@ -219,7 +241,8 @@ def delete_old_feed_items(adwords, feed_item_ids, feed)
|
|
219
241
|
feed_item_srv.mutate(operations)
|
220
242
|
end
|
221
243
|
|
222
|
-
def create_extension_setting(
|
244
|
+
def create_extension_setting(
|
245
|
+
adwords, feed_items, campaign_feed, feed_item_ids, platform_restrictions)
|
223
246
|
campaign_extension_setting_srv = adwords.service(
|
224
247
|
:CampaignExtensionSettingService, API_VERSION)
|
225
248
|
|
@@ -254,6 +277,10 @@ def create_extension_setting(adwords, feed_items, campaign_feed, feed_item_ids)
|
|
254
277
|
:extensions => extension_feed_items
|
255
278
|
}
|
256
279
|
|
280
|
+
unless platform_restrictions.nil?
|
281
|
+
extension_setting[:platform_restrictions] = platform_restrictions
|
282
|
+
end
|
283
|
+
|
257
284
|
campaign_extension_setting = {
|
258
285
|
:campaign_id => campaign_feed[:campaign_id],
|
259
286
|
:extension_type => 'SITELINK',
|
@@ -47,7 +47,7 @@ def parallel_report_download()
|
|
47
47
|
selector = {:fields => ['CustomerId']}
|
48
48
|
|
49
49
|
# Run the request at the MCC level.
|
50
|
-
graph =
|
50
|
+
graph = managed_customer_srv.get(selector)
|
51
51
|
|
52
52
|
# Using queue to balance load between threads.
|
53
53
|
queue = Queue.new()
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# Author:: api.mcloonan@gmail.com (Michael Cloonan)
|
5
5
|
#
|
6
|
-
# Copyright:: Copyright
|
6
|
+
# Copyright:: Copyright 2015, Google Inc. All Rights Reserved.
|
7
7
|
#
|
8
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
9
|
# you may not use this file except in compliance with the License.
|
@@ -18,16 +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 an ad customizer feed
|
22
|
-
#
|
21
|
+
# This example adds an ad customizer feed using Extension Services. Then it adds
|
22
|
+
# an ad that uses the feed to populate dynamic data.
|
23
23
|
#
|
24
|
-
# Tags:
|
25
|
-
# Tags: FeedMappingService.mutate, FeedService.mutate
|
24
|
+
# Tags: AdCustomizerFeedService.mutate, FeedItemService.mutate
|
26
25
|
# Tags: AdGroupAdService.mutate
|
27
26
|
|
28
27
|
require 'adwords_api'
|
28
|
+
require 'date'
|
29
29
|
|
30
|
-
def
|
30
|
+
def add_ad_customizers(feed_name, ad_group_ids)
|
31
31
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
32
32
|
# when called without parameters.
|
33
33
|
adwords = AdwordsApi::Api.new
|
@@ -36,95 +36,26 @@ def add_ad_customizer(ad_group_ids)
|
|
36
36
|
# the configuration file or provide your own logger:
|
37
37
|
# adwords.logger = Logger.new('adwords_xml.log')
|
38
38
|
|
39
|
-
feed_srv = adwords.service(:FeedService, API_VERSION)
|
40
39
|
feed_item_srv = adwords.service(:FeedItemService, API_VERSION)
|
41
|
-
feed_mapping_srv = adwords.service(:FeedMappingService, API_VERSION)
|
42
|
-
customer_feed_srv = adwords.service(:CustomerFeedService, API_VERSION)
|
43
40
|
ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
|
44
41
|
|
45
|
-
#
|
46
|
-
|
47
|
-
customizer_feed = {
|
48
|
-
:name => 'CustomizerFeed',
|
49
|
-
:attributes => [
|
50
|
-
{:type => 'STRING', :name => 'Name'},
|
51
|
-
{:type => 'STRING', :name => 'Price'},
|
52
|
-
{:type => 'DATE_TIME', :name => 'Date'}
|
53
|
-
]
|
54
|
-
}
|
55
|
-
|
56
|
-
response = feed_srv.mutate([
|
57
|
-
{:operator => 'ADD', :operand => customizer_feed}
|
58
|
-
])
|
59
|
-
|
60
|
-
feed_data = {}
|
61
|
-
if response and response[:value]
|
62
|
-
feed = response[:value].first
|
63
|
-
feed_data = {
|
64
|
-
:feed_id => feed[:id],
|
65
|
-
:name_id => feed[:attributes][0][:id],
|
66
|
-
:price_id => feed[:attributes][1][:id],
|
67
|
-
:date_id => feed[:attributes][2][:id]
|
68
|
-
}
|
69
|
-
puts "Feed with name '%s' and ID %d was added with:" %
|
70
|
-
[feed[:name], feed[:id]]
|
71
|
-
puts ("\tName attribute ID %d and price attribute ID %d " +
|
72
|
-
"and date attribute ID %d.") % [
|
73
|
-
feed_data[:name_id],
|
74
|
-
feed_data[:price_id],
|
75
|
-
feed_data[:date_id]
|
76
|
-
]
|
77
|
-
else
|
78
|
-
raise new StandardError, 'No feeds were added.'
|
79
|
-
end
|
80
|
-
|
81
|
-
# Creating feed mapping to map the fields with customizer IDs.
|
82
|
-
feed_mapping = {
|
83
|
-
:placeholder_type => PLACEHOLDER_AD_CUSTOMIZER,
|
84
|
-
:feed_id => feed_data[:feed_id],
|
85
|
-
:attribute_field_mappings => [
|
86
|
-
{
|
87
|
-
:feed_attribute_id => feed_data[:name_id],
|
88
|
-
:field_id => PLACEHOLDER_FIELD_STRING
|
89
|
-
},
|
90
|
-
{
|
91
|
-
:feed_attribute_id => feed_data[:price_id],
|
92
|
-
:field_id => PLACEHOLDER_FIELD_PRICE
|
93
|
-
},
|
94
|
-
{
|
95
|
-
:feed_attribute_id => feed_data[:date_id],
|
96
|
-
:field_id => PLACEHOLDER_FIELD_DATE
|
97
|
-
}
|
98
|
-
]
|
99
|
-
}
|
100
|
-
|
101
|
-
response = feed_mapping_srv.mutate([
|
102
|
-
{:operator => 'ADD', :operand => feed_mapping}
|
103
|
-
])
|
104
|
-
if response and response[:value]
|
105
|
-
feed_mapping = response[:value].first
|
106
|
-
puts ('Feed mapping with ID %d and placeholder type %d was saved for feed' +
|
107
|
-
' with ID %d.') % [
|
108
|
-
feed_mapping[:feed_mapping_id],
|
109
|
-
feed_mapping[:placeholder_type],
|
110
|
-
feed_mapping[:feed_id]
|
111
|
-
]
|
112
|
-
else
|
113
|
-
raise new StandardError, 'No feed mappings were added.'
|
114
|
-
end
|
42
|
+
# Create a customizer feed. One feed per account can be used for all ads.
|
43
|
+
feed_data = create_customizer_feed(adwords, feed_name)
|
115
44
|
|
116
45
|
# Now adding feed items -- the values we'd like to place.
|
46
|
+
now_date = Date.today()
|
47
|
+
|
117
48
|
items_data = [
|
118
49
|
{
|
119
50
|
:name => 'Mars',
|
120
51
|
:price => '$1234.56',
|
121
|
-
:date => '
|
52
|
+
:date => now_date.strftime('%Y%m01 000000'),
|
122
53
|
:ad_group_id => ad_group_ids[0]
|
123
54
|
},
|
124
55
|
{
|
125
56
|
:name => 'Venus',
|
126
57
|
:price => '$1450.00',
|
127
|
-
:date => '
|
58
|
+
:date => now_date.strftime('%Y%m15 000000'),
|
128
59
|
:ad_group_id => ad_group_ids[1]
|
129
60
|
}
|
130
61
|
]
|
@@ -165,38 +96,6 @@ def add_ad_customizer(ad_group_ids)
|
|
165
96
|
raise new StandardError, 'No feed items were added.'
|
166
97
|
end
|
167
98
|
|
168
|
-
# Finally, creating a customer (account-level) feed with a matching function
|
169
|
-
# that determines when to use this feed. For this case we use the "IDENTITY"
|
170
|
-
# matching function that is always 'true' just to associate this feed with
|
171
|
-
# the customer. The targeting is done within the feed items using the
|
172
|
-
# :campaign_targeting, :ad_group_targeting, or :keyword_targeting attributes.
|
173
|
-
matching_function = {
|
174
|
-
:operator => 'IDENTITY',
|
175
|
-
:lhs_operand => [
|
176
|
-
{
|
177
|
-
:xsi_type => 'ConstantOperand',
|
178
|
-
:type => 'BOOLEAN',
|
179
|
-
:boolean_value => true
|
180
|
-
}
|
181
|
-
]
|
182
|
-
}
|
183
|
-
|
184
|
-
customer_feed = {
|
185
|
-
:feed_id => feed_data[:feed_id],
|
186
|
-
:matching_function => matching_function,
|
187
|
-
:placeholder_types => [PLACEHOLDER_AD_CUSTOMIZER]
|
188
|
-
}
|
189
|
-
|
190
|
-
response = customer_feed_srv.mutate([
|
191
|
-
{:operator => 'ADD', :operand => customer_feed}
|
192
|
-
])
|
193
|
-
if response and response[:value]
|
194
|
-
feed = response[:value].first
|
195
|
-
puts 'Customer feed with ID %d was added.' % [feed[:feed_id]]
|
196
|
-
else
|
197
|
-
raise new StandardError, 'No customer feeds were added.'
|
198
|
-
end
|
199
|
-
|
200
99
|
# All set! We can now create ads with customizations.
|
201
100
|
text_ad = {
|
202
101
|
:xsi_type => 'TextAd',
|
@@ -214,7 +113,7 @@ def add_ad_customizer(ad_group_ids)
|
|
214
113
|
:operator => 'ADD',
|
215
114
|
:operand => {
|
216
115
|
:ad_group_id => ad_group_id,
|
217
|
-
:ad => text_ad
|
116
|
+
:ad => text_ad.dup()
|
218
117
|
}
|
219
118
|
}
|
220
119
|
end
|
@@ -231,25 +130,38 @@ def add_ad_customizer(ad_group_ids)
|
|
231
130
|
end
|
232
131
|
end
|
233
132
|
|
133
|
+
def create_customizer_feed(adwords, feed_name)
|
134
|
+
ad_customizer_srv = adwords.service(:AdCustomizerFeedService, API_VERSION)
|
135
|
+
feed = {
|
136
|
+
:feed_name => feed_name,
|
137
|
+
:feed_attributes => [
|
138
|
+
{:name => 'Name', :type => 'STRING'},
|
139
|
+
{:name => 'Price', :type => 'PRICE'},
|
140
|
+
{:name => 'Date', :type => 'DATE_TIME'}
|
141
|
+
]
|
142
|
+
}
|
143
|
+
operation = {:operand => feed, :operator => 'ADD'}
|
144
|
+
added_feed = ad_customizer_srv.mutate([operation])[:value].first()
|
145
|
+
puts "Created ad customizer feed with ID = %d and name = '%s'." %
|
146
|
+
[added_feed[:feed_id], added_feed[:feed_name]]
|
147
|
+
return {
|
148
|
+
:feed_id => added_feed[:feed_id],
|
149
|
+
:name_id => added_feed[:feed_attributes][0][:id],
|
150
|
+
:price_id => added_feed[:feed_attributes][1][:id],
|
151
|
+
:date_id => added_feed[:feed_attributes][2][:id]
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
234
155
|
if __FILE__ == $0
|
235
156
|
API_VERSION = :v201502
|
236
157
|
|
237
|
-
# See the Placeholder reference page for a list of all the placeholder types
|
238
|
-
# and fields:
|
239
|
-
# https://developers.google.com/adwords/api/docs/appendix/placeholders
|
240
|
-
PLACEHOLDER_AD_CUSTOMIZER = 10
|
241
|
-
PLACEHOLDER_FIELD_INTEGER = 1
|
242
|
-
PLACEHOLDER_FIELD_FLOAT = 2
|
243
|
-
PLACEHOLDER_FIELD_PRICE = 3
|
244
|
-
PLACEHOLDER_FIELD_DATE = 4
|
245
|
-
PLACEHOLDER_FIELD_STRING = 5
|
246
|
-
|
247
158
|
begin
|
159
|
+
feed_name = 'INSERT_FEED_NAME_HERE'.to_s
|
248
160
|
ad_group_ids = [
|
249
161
|
'INSERT_AD_GROUP_ID_HERE'.to_i,
|
250
162
|
'INSERT_AD_GROUP_ID_HERE'.to_i
|
251
163
|
]
|
252
|
-
|
164
|
+
add_ad_customizers(feed_name, ad_group_ids)
|
253
165
|
|
254
166
|
# Authorization error.
|
255
167
|
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|