We are using a script to pull cost and week data from Google Ads and we think that ACCOUNT_PERFORMANCE_REPORT is responsible for displaying incorrect cost numbers, as it does not include the Performance Max campaigns.
Here's the code and it was working normally before the introduction of Pmaxes.
Can someone please help with it?
We wonder if the AdWordsApp.report part in the code (as opposed to using the new AdsApp.report) is not causing it, or is it rather Pmax not being supported right now?
Here's the text version of the script below as well:
function main() {
var SPREADSHEET_URL = 'X';
// Name of the specific sheet in the spreadsheet.
var SHEET_NAME = 'AT';
var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = ss.getSheetByName(SHEET_NAME);
//Append the row header is sheet is empty
if (sheet.getLastRow() == 0) {
sheet.appendRow(['Week from', 'Cost (Mon-Sun)']);
}
var report = AdWordsApp.report(
'SELECT Cost ' +
'FROM ACCOUNT_PERFORMANCE_REPORT ' +
'DURING LAST_WEEK');
var rows = report.rows();
var timeZone = AdWordsApp.currentAccount().getTimeZone();
var now = new Date;
var startDate = new Date(now.getTime() - (7 * 24 * 3600 * 1000));
var formatedDate = Utilities.formatDate(startDate, timeZone, 'dd/MM/YYYY');
while (rows.hasNext()) {
var row = rows.next();
sheet.appendRow([formatedDate,row['Cost']]);
}