Seeing Cost Multiplied by 1000000?

450 views
Skip to first unread message

Burak

unread,
Jan 27, 2022, 8:28:36 PM1/27/22
to Google Ads Scripts Forum
Hi everyone,

I exported daily cost to a spreadsheet but I see cost multiplied by 1 million.
I know I can divide them by 1000000 but anyone has a solution for this? 

I use metrics.cost_micros as a metric.


Google Ads Scripts Forum Advisor

unread,
Jan 28, 2022, 2:02:49 AM1/28/22
to adwords...@googlegroups.com
Hi Burak,

Thanks for reaching out. Harry here, from the Google Ads Scripts Team.

The metrics.cost_micros field will be returned in the micros format as an intended behavior. When using the AdsApp.report object, you can set the optional argument returnMoneyInMicros to false or simply divide each cost value by 1000000 as you have stated.

Thanks,
Google Logo
Harry Cliford Rivera
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2VQLid:ref

Nils Rooijmans

unread,
Jan 29, 2022, 6:17:26 AM1/29/22
to Google Ads Scripts Forum
Hi Burak,

You need to convert this micros value to your currency within your script. Here's a function you can use to do so:

// convert money data type to currency cost value
function convertMoney(m) {
  return m / 1000000;
}



Hope this helps,

Nils Rooijmans
https://nilsrooijmans.com
See my Google Ads Scripts FAQ to avoid the same mistakes I made: https://nilsrooijmans.com/google-ads-scripts-faq/

Google Ads Scripts Forum Advisor

unread,
Jan 31, 2022, 2:02:39 AM1/31/22
to adwords...@googlegroups.com

Hello Nils,

 

I'm Michael and I work along with Harry.

 

Thank you for sharing your insight and a sample code snippet for resolution.

 

@Burak, the solution provided by Harry and Nils should be able to addressed your concern. Let us know should you have further questions.

Regards,

Google Logo
Michael Angelo Legaspi
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2VQLid:ref

Yan Lahud

unread,
Jun 15, 2022, 4:40:37 PM6/15/22
to Google Ads Scripts Forum
Hello everyone! How i can do this in my code? Can yours help me, please? 

My code:

function main() {
 
  // Dados da planilha
  var spreadsheet = SpreadsheetApp.openByUrl('XXXXX');
  var sheet = spreadsheet.getSheetByName('XXXX');
 
  // Query com os dados
  const query = 'SELECT campaign.name, metrics.clicks, metrics.impressions, metrics.cost_micros FROM campaign WHERE segments.date >= \'2022-06-01\' AND segments.date < \'2022-06-04\'';
 
  var report = AdWordsApp.report(query);
 
  // Log de erro
  Logger.log(report);
 
  // Exportando dados para a planilha
  report.exportToSheet(sheet);
Reply all
Reply to author
Forward
0 new messages