I am using http://ift.tt/2mwfMCG gem for using adwords api for OfflineConversionFeedService. Code looks alright:
module AdwordsHelper
def mark_conversion_in_ads(customer)
begin
config_filename = File.join(Rails.root, 'config', 'adwords_api.yml')
adwords = AdwordsApi::Api.new(config_filename)
conversion_feed_srv =
adwords.service(:OfflineConversionFeedService, :v201702)
conversion_time = Time.new.strftime("%Y%m%d %H%M%S")
conversion_value = '100'.to_f
feed = {
:google_click_id => customer.gclid,
:conversion_name => 'LeadCreatedAll',
:conversion_time => conversion_time,
:conversion_value => conversion_value,
:conversion_currency_code => 'GBP'
}
return_feeds = conversion_feed_srv.mutate([
{:operator => 'ADD', :operand => feed}])
return_feeds[:value].each do |return_feed|
puts ("Uploaded offline conversion value %.2f for Google Click ID '%s', " +
'to %s') % [return_feed[:conversion_value],
return_feed[:google_click_id],
return_feed[:conversion_name]]
end
rescue AdwordsApi::Errors::ApiException => e
puts e.backtrace
Logger.log_message("Exception occurred: %s\n%s" % [e.to_s, e.message])
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
"to retrieve and store OAuth2 tokens."
puts "See this wiki page for more details:\n\n " +
'http://ift.tt/1di4CsR'
# HTTP errors.
rescue AdsCommon::Errors::HttpError => e
puts "HTTP Error: %s" % e
# API errors.
rescue AdwordsApi::Errors::ApiException => e
puts "Message: %s" % e.message
puts 'Errors:'
e.errors.each_with_index do |error, index|
puts "\tError [%d]:" % (index + 1)
error.each do |field, value|
puts "\t\t%s: %s" % [field, value]
end
end
end
end
end
My adwords_api.yml file is:
---
:authentication:
:method: OAUTH2_SERVICE_ACCOUNT
:oauth2_keyfile: "/path/to_server_account_file/jsonkey.json"
:developer_token: test_level_developer_token_of_production_manager_account
:client_customer_id: client_customer_id_of_test_manager_account
:oauth2_token:
:access_token: access_token_generated_setup_oauth.rb
:issued_at: 2017-03-16 13:12:25.005441000 +05:30
:expires_in: 3600
:id_token:
:service:
:environment: PRODUCTION
:connection:
:enable_gzip: false
:library:
:log_level: INFO
I have been trying to test this setup for a long time and am getting this error: Exception occurred: [AuthenticationError.NOT_ADS_USER @ ; trigger:''] [AuthenticationError.NOT_ADS_USER @ ; trigger:'']
I have tried a lot of links: managing test accounts
Can someone please provide exact steps on how to test it out. For some more clarification, I have Test Account developer key in adwords.
Using adwords api v201702 The api I am trying to use is OfflineConversion
Aucun commentaire:
Enregistrer un commentaire