error in skript for Google Skripts

141 views
Skip to first unread message

Nicole Havranek

unread,
Jun 13, 2023, 10:23:41 AM6/13/23
to Google Ads Scripts Forum
Hi, I can´t find the the error, what does this error-message mean? 

This is the skript: I want to use: 

13.6.2023 15:27:32

Ga: Unrecognized function name "main"



/**

Configuration to be used for the Account Summary Report.
*/
CONFIG = {
// URL of the report spreadsheet. This should be a copy of
// https://docs.google.com/spreadsheets/d/1gYLXtDK93lWoTe3OBKvTlfcc7L_qHJFgWU9N6HwhZtU/copy
'spreadsheet_url': 'https://docs.google.com/spreadsheets/d/1yw4nCRW1XdqEmm6ZCanWmSz74Jp4cKBga6C58Qg_oAQ/edit#gid=1558995445',
// More reporting options can be found at
// https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp#report_2
'reporting_options': {
// Comment out the following line to default to the latest reporting
// version.
},
/**

To add additional fields to the report, follow the instructions at
https://developers.google.com/google-ads/scripts/docs/solutions/account-summary#extending_the_report_optional
*/
'report_fields': [
{'columnName': 'metrics.cost_micros', 'displayName': 'Cost'},
]
};
function exportReportToSpreadsheet() {
const spreadsheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1yw4nCRW1XdqEmm6ZCanWmSz74Jp4cKBga6C58Qg_oAQ/edit#gid=1558995445');
const sheet = spreadsheet.getSheetByName('test');

const query = 'SELECT campaign.name, metrics.cost_micros ' +
'FROM campaign ' +
'WHERE campaign.name CONTAINS "|FR" ' +
'AND segments.date DURING LAST_WEEK MONDAY';

const report = AdsApp.report(query);

const reportRows = report.rows();
const headerRow = reportHeaders(report);
sheet.getRange(1, 1, 1, headerRow.length).setValues([headerRow]);

let row = 2;
while (reportRows.hasNext()) {
const rowData = reportRows.next();
const values = reportRowValues(rowData);
sheet.getRange(row, 1, 1, values.length).setValues([values]);
row++;
}

spreadsheet.rename('production Marketing-table - (hepster - Webshop & Marketing - Weekly Overview)');
}

function reportHeaders(report) {
const headers = report.columnHeaders();
const headerRow = [];

while (headers.hasNext()) {
headerRow.push(headers.next().getFieldName());
}

return headerRow;
}

function reportRowValues(rowData) {
const values = [];

for (const key in rowData) {
values.push(rowData[key]);
}

return values;
}

Omnicom Digital

unread,
Jun 13, 2023, 10:30:34 AM6/13/23
to Google Ads Scripts Forum
You need to have one "main()" function that is executed when you press "Run script".
In your case, "exportReportToSpreadsheet()" should be renamed to "main()".

Nicole Havranek

unread,
Jun 13, 2023, 10:39:03 AM6/13/23
to Google Ads Scripts Forum

 

After changing, I get a new error:

 

 

/Nicole

--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/qNARdSj21so/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/3984ef24-5de7-4af4-8aa9-ea090f39a765n%40googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
Jun 16, 2023, 9:13:26 AM6/16/23
to adwords...@googlegroups.com

Hi All,

 

Thank you for reaching out to the Google Ads Scripts Forum Channel.

 

@Omnicom Digital Team - Thank you for your insights here.

 

@Nicole - Please note that I had to remove your previous response. I'm afraid that posting messages containing personal information in this forum is not recommended as it is public.

 

Upon checking, it appears that you've made updates to the Account Summary solution script <https://developers.google.com/google-ads/scripts/docs/solutions/account-summary> and are encountering a error as you had omitted a huge chunk of the code and used methods or functions which do not exist. Please do note that it's not recommended to make changes to the solution script, as it has an intended function, and making a lot of changes would cause the script to break. With this, I would recommend implementing the script as is.

 

On that note, could you please confirm if you're looking for a different function regarding the said script and would like to modify it? If yes, we'd highly appreciate it if you could provide your requirements of the script in bullet form so our team can be able to have a better understanding of what you're aiming for and assist you.

 

This message is in relation to case "ref:_00D1U1174p._5004Q2mCU2M:ref"

Thanks,
 
Google Logo Google Ads Scripts Team


Reply all
Reply to author
Forward
0 new messages