diff --git a/examples/remarketing/add_customer_match_user_list.rb b/examples/remarketing/add_customer_match_user_list.rb index 0d89ac3f..6d8513ac 100644 --- a/examples/remarketing/add_customer_match_user_list.rb +++ b/examples/remarketing/add_customer_match_user_list.rb @@ -89,7 +89,7 @@ def add_users_to_customer_match_user_list(client, customer_id, run_job, user_lis client.resource.customer_match_user_list_metadata do |m| m.user_list = user_list - unless ad_user_data_consent.nil? && ad_personalization_consent.nil? + if !gclid.nil? || !gclid.nil? m.consent = client.resource.consent do |c| # Specifies whether user consent was obtained for the data you are # uploading. For more details, see: diff --git a/examples/remarketing/upload_call_conversion.rb b/examples/remarketing/upload_call_conversion.rb index 40487e69..9e43da7f 100644 --- a/examples/remarketing/upload_call_conversion.rb +++ b/examples/remarketing/upload_call_conversion.rb @@ -56,7 +56,7 @@ def upload_call_conversion( end unless ad_user_data_consent.nil? - m.consent = client.resource.consent do |c| + c.consent = client.resource.consent do |c| # Specifies whether user consent was obtained for the data you are # uploading. For more details, see: # https://www.google.com/about/company/user-consent-policy @@ -127,6 +127,7 @@ def upload_call_conversion( # associate with the call conversion upload. options[:conversion_custom_variable_id] = nil; options[:conversion_custom_variable_value] = nil; + options[:ad_user_data_consent] = nil; OptionParser.new do |opts| opts.banner = sprintf('Usage: %s [options]', File.basename(__FILE__)) @@ -158,19 +159,19 @@ def upload_call_conversion( options[:conversion_value] = v.to_f end - opts.on('-d', '--conversion-custom-variable-id CONVERSION-CUSTOM-VARIABLE-ID', \ + opts.on('-w', '--conversion-custom-variable-id CONVERSION-CUSTOM-VARIABLE-ID', \ String, '(Optional) The ID of the conversion custom variable to ' \ 'associate with the upload') do |v| options[:conversion_custom_variable_id] = v end - opts.on('-d', '--conversion-custom-variable-value CONVERSION-CUSTOM-VARIABLE-VALUE', \ + opts.on('-x', '--conversion-custom-variable-value CONVERSION-CUSTOM-VARIABLE-VALUE', \ String, '(Optional) The value of the conversion custom ' \ 'variable to associate with the upload') do |v| options[:conversion_custom_variable_value] = v end - opts.on('-u', '--ad-user-data-consent AD-USER-DATA_CONSENT', \ + opts.on('-d', '--ad-user-data-consent AD-USER-DATA_CONSENT', \ String, '(Optional) The data consent status for ad user data for all members in the job.' \ 'e.g. UNKNOWN, GRANTED, DENIED') do |v| options[:ad_user_data_consent] = v diff --git a/examples/remarketing/upload_enhanced_conversions_for_leads.rb b/examples/remarketing/upload_enhanced_conversions_for_leads.rb index f162a5b5..23d292d9 100644 --- a/examples/remarketing/upload_enhanced_conversions_for_leads.rb +++ b/examples/remarketing/upload_enhanced_conversions_for_leads.rb @@ -92,9 +92,9 @@ def upload_conversion_with_identifiers( # uploading. For more details, see: # https://www.google.com/about/company/user-consent-policy unless raw_record["ad_user_data_consent"].nil? - # cc.consent.ad_user_data = client.enums.ConsentStatusEnum[ - # raw_record["ad_user_data_consent"] - # ] + cc.consent = client.resource.consent do |c| + c.ad_user_data = ad_user_data_consent + end end # [END add_conversion_details] @@ -117,6 +117,7 @@ def upload_conversion_with_identifiers( end # [END add_user_identifiers] + # [START upload_conversion] response = client.service.conversion_upload.upload_click_conversions( customer_id: customer_id, conversions: [click_conversion], @@ -131,6 +132,7 @@ def upload_conversion_with_identifiers( puts "Uploaded click conversion that happened at #{result.conversion_date_time} " \ "to #{result.conversion_action}." end + # [END upload_conversion] end # [START normalize_and_hash] @@ -173,8 +175,8 @@ def normalize_and_hash_email(email) options[:conversion_date_time] = 'INSERT_CONVERSION_DATE_TIME_HERE' options[:conversion_value] = 'INSERT_CONVERSION_VALUE_HERE' options[:order_id] = nil - options[:gclid] = 'INSERT_GCLID_HERE' - options[:ad_user_data_consent] = 'INSERT_AD_USER_DATA_CONSENT_ENUM_HERE' + options[:gclid] = nil + options[:ad_user_data_consent] = nil OptionParser.new do |opts| opts.banner = sprintf('Usage: %s [options]', File.basename(__FILE__)) @@ -211,7 +213,8 @@ def normalize_and_hash_email(email) opts.on('-d', '--ad-user-data-dconsent GCLID', String, 'The data consent status for ad user data for all members in' \ - 'the job.') do |v| + 'the job.' \ + 'e.g. UNKNOWN, GRANTED, DENIED') do |v| options[:ad_user_data_consent] = v end diff --git a/examples/remarketing/upload_store_sales_transactions.rb b/examples/remarketing/upload_store_sales_transactions.rb index 7ceeb722..b6ac3355 100644 --- a/examples/remarketing/upload_store_sales_transactions.rb +++ b/examples/remarketing/upload_store_sales_transactions.rb @@ -39,7 +39,9 @@ def upload_store_sales_transactions( merchant_center_account_id, region_code, language_code, - quantity) + quantity, + ad_user_data_consent, + ad_personalization_consent) # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new @@ -66,6 +68,8 @@ def upload_store_sales_transactions( offline_user_data_job_resource_name, conversion_action_id, custom_value, + ad_user_data_consent, + ad_personalization_consent ) # Issues an asynchronous request to run the offline user data job. @@ -181,10 +185,13 @@ def add_transactions_to_offline_user_data_job( customer_id, offline_user_data_job_resource_name, conversion_action_id, - custom_value) + custom_value, + ad_user_data_consent, + ad_personalization_consent) # Constructs the operation for each transaction. user_data_job_operations = build_offline_user_data_job_operations( - client, customer_id, conversion_action_id, custom_value) + client, customer_id, conversion_action_id, custom_value, ad_user_data_consent, + ad_personalization_consent) # [START enable_warnings_1] # Issues a request to add the operations to the offline user data job. @@ -238,7 +245,9 @@ def build_offline_user_data_job_operations( client, customer_id, conversion_action_id, - custom_value) + custom_value, + ad_user_data_consent, + ad_personalization_consent) operations = [] # Creates the first transaction for upload based on an email address @@ -267,6 +276,19 @@ def build_offline_user_data_job_operations( t.transaction_date_time = "2020-05-01 23:52:12" t.custom_value = custom_value unless custom_value.nil? end + if !gclid.nil? || !gclid.nil? + job.consent = client.resource.consent do |c| + # Specifies whether user consent was obtained for the data you are + # uploading. For more details, see: + # https://www.google.com/about/company/user-consent-policy + unless ad_user_data_consent.nil? + c.ad_user_data = ad_user_data_consent + end + unless ad_personalization_consent.nil? + c.ad_personalization = ad_personalization_consent + end + end + end end # Creates the second transaction for upload based on a physical address. @@ -466,6 +488,18 @@ def check_job_status( options[:quantity] = v end + opts.on('-d', '--ad-user-data-consent [AD-USER-DATA_CONSENT]', String, + 'The personalization consent status for ad user data for all members in the job.' \ + 'e.g. UNKNOWN, GRANTED, DENIED') do |v| + options[:ad_user_data_consent] = v + end + + opts.on('-p', '--ad-personalization-consent [AD-PERSONALIZATION-CONSENT]', String, + 'The personalization consent status for ad user data for all members in the job.' \ + 'e.g. UNKNOWN, GRANTED, DENIED') do |v| + options[:ad_personalization_consent] = v + end + opts.separator '' opts.separator 'Help:' @@ -491,6 +525,8 @@ def check_job_status( options[:region_code], options[:language_code], options[:quantity], + options[:ad_user_data_consent], + options[:ad_personalization_consent], ) rescue Google::Ads::GoogleAds::Errors::GoogleAdsError => e e.failure.errors.each do |error|