AdWords
4.5K members online now
4.5K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

Total Conversion Value/ Conversion Value in Scripts

[ Edited ]
Follower ✭ ✭ ☆
# 1
Follower ✭ ✭ ☆

Hi all,

 

I am new to the world with scripts and I am currently trying to produce a report that shows me every campaign and mainly their costs and the conversion value. So far I got this function:

 

function main() {
var spreadsheet = SpreadsheetApp.create('*******');
var report = AdWordsApp.report(
'SELECT CampaignName, Clicks, Cost ' +
'FROM CAMPAIGN_PERFORMANCE_REPORT ' +
'DURING LAST_30_DAYS');
report.exportToSheet(spreadsheet.getActiveSheet());
}

 

Is there a function or anything that I can add so that I can see the Total Conversion Value/ Conversion Value?

And is there also a way to change the date range easily from "30 days" to "this month till today"?

OR is there a metric that can show me "All conversion value/ cost"?

 

I hope you can help me with this.

Thanks a lot,

 

Nico

1 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by topic author Nico Rentschler
February 2017

Re: Total Conversion Value/ Conversion Value in Scripts

Top Contributor
# 2
Top Contributor

Hi @Nico l not sure if you're already using these pages, but they're a good reference for what fields are available in the various reports.  This page:

 

https://developers.google.com/adwords/api/docs/appendix/reports/campaign-performance-report

 

shows the Campaign Performance Report and if you look to the right, you'll see there are various fields for conversion values, all and any of which could be included in your SELECT statement.  There is no specific field for conversion value/cost but that's simply a calculation.  One thing to watch out for, the value returned for conversion value is, for some unknown reason, a string, not a numeric, so you should probably check to replace any commas for thousands and then cast the value to a number.  For example, this is a line from one of my scripts:

var ROAS = (thisValue.replace(",","") / thisCost.replace(",","")).toFixed(2);

where thisValue and thisCost are values returned from a report similar to the Campaign Performance Report.  This line replaces any commas, divides value by cost and then fixes the result to two decimal places.

 

Rather than exporting the whole result of the query to a spreadsheet, you'll probably find it easier to take the values returned, process them in your script then export individual lines to the sheet.  This is really quite simple, for example:

var thisSheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL).getSheetByName(SHEET_NAME);
thisSheet.appendRow([value1, value2, value3]);

where SPREADSHEET_URL and SHEET_NAME are vars defining those values.  Appending rows in this way will place value1value2 and value3 in columns A, B and C of the first "empty" row in the sheet.

 

Working with sheets this way allows you to a lot more processing of the data before it hits the spreadsheet, so you could send email alerts, add notes to the sheet, etc. etc.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

Total Conversion Value/ Conversion Value in Scripts

Follower ✭ ✭ ☆
# 3
Follower ✭ ✭ ☆

Hi Jon,

 

Thanks a lot for your reply and useful help with this.

Can you tell me or confirm that if I easily could copy the first "function" to then paste into my main function or is there anything I should look out for.

 

The thing is I want to see the Conversion Value for all my campaigns that the report will show me, do I have to add either of the functions you have provided to a certain position in my function?

 

Thanks,

 

Nico