Google Ad Reporting Summary

195 views
Skip to first unread message

Dorian Lee

unread,
Jun 19, 2024, 1:44:48 AM6/19/24
to Google Ads Scripts Forum
hey guys

I am trying to use ad script to transfer data to Google sheet. However, i got an error 

ReferenceError: CONFIG is not defined (line 1)

you can find my config code below. 

/**
 * 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/1Jk-EKK8NGnjV5NbMKzADcWPsqxTriyz7J-hgLZRm0Wc/edit?gid=0#gid=0',
  // 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.
    'apiVersion': 'v10'
  },
  /**
   * 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'},
    {'columnName': 'metrics.average_cpc', 'displayName': 'Avg. CPC'},
    {'columnName': 'metrics.ctr', 'displayName': 'CTR'},
    {'columnName': 'metrics.search_impression_share', 'displayName': 'Search Impr. share'},
    {'columnName': 'metrics.impressions', 'displayName': 'Impressions'},
    {'columnName': 'metrics.clicks', 'displayName': 'Clicks'}
  ]
};


dont really know how to solve it. would appreciate your help!
thank you

Google Ads Scripts Forum Advisor

unread,
Jun 19, 2024, 2:53:36 AM6/19/24
to adwords...@googlegroups.com

Hi,

Thank you for reaching out to the Google Ads Scripts support team.

I would suggest you to use the Source code available in the Google Ads Scripts solutions tab for account summary report. Kindly change the reporting version in the line 58 as ‘v16’ or else comment out the ‘apiVersion’ line to set it to the latest version.

I hope this helps. If the issue still persists even after following the above steps, Kindly get back to us with the below details.

  • Google Ads account ID/CID
  • Name of the affected script
  • Shareable spreadsheet link if you are using in your script
You can share the requested details via Reply privately to the author option or a direct private reply to this email. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02tJOc4:ref" (ADR-00242402)

Thanks,
 
Google Logo Google Ads Scripts Team


Dorian Lee

unread,
Jun 19, 2024, 9:39:29 PM6/19/24
to Google Ads Scripts Forum

Hey dear Scripts Team

i can only replay to all which is frustrating..

unfortunately I can’t use the source code directly as we need to make customization to the reporting format and metrics.

You can find the required details below:

Regards

Google Ads Scripts Forum Advisor

unread,
Jun 20, 2024, 3:41:59 AM6/20/24
to adwords...@googlegroups.com
Hi,

Based on the provided information, I could see that you've encountered the error "ReferenceError: CONFIG is not defined" while running a script. I would like to inform you that you are getting an error message because the CONFIG variable is not defined in your script. In order to fix this error, I suggest you make sure that the variable config is defined in the script. You can do this by adding the below code to your script and let us know if you still encounter the error. 
  'reporting_options': {
    // Comment out the following line to default to the latest reporting
    // version.
    'apiVersion': 'v16'
  },
  /**
   * 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'},
    {'columnName': 'metrics.average_cpc', 'displayName': 'Avg. CPC'},
    {'columnName': 'metrics.ctr', 'displayName': 'CTR'},
    {'columnName': 'metrics.search_impression_share', 'displayName': 'Search Impr. share'},
    {'columnName': 'metrics.impressions', 'displayName': 'Impressions'},
    {'columnName': 'metrics.clicks', 'displayName': 'Clicks'}
  ]
};
const SPREADSHEET_URL = CONFIG.spreadsheet_url;

Dorian Lee

unread,
Jun 20, 2024, 5:25:19 AM6/20/24
to Google Ads Scripts Forum
just tried this and encounter the same issue.. 

Nguyễn Thu Hoài

unread,
Jun 20, 2024, 7:40:42 AM6/20/24
to Google Ads Scripts Forum

Hi Scripts Team,
I want to export a report to see how the performance max campaign's impressions are distributed across networks. I used this code to upload the script but I get an error. Please help me see what I need to do to fix it.

Dorian Lee

unread,
Jun 24, 2024, 1:31:26 AM6/24/24
to Google Ads Scripts Forum
Hi Dear Script Team

Do you have a chance to help it out? I can see you created another script but the same issue persists.. not really sure what would be the issue at this stage.

Google Ads Scripts Forum Advisor

unread,
Jun 24, 2024, 3:48:13 AM6/24/24
to adwords...@googlegroups.com

Hi,

I would like to inform you that “Exception: You do not have permission to access the requested document.” the error in the script our team created is regarding the spreadsheet access. I would suggest that you execute the script after defining the CONFIG variable in the code at your end and get back to us if the issue still persists.

Nils Rooijmans

unread,
Sep 21, 2024, 3:56:34 AM9/21/24
to Google Ads Scripts Forum
With respsect to “Exception: You do not have permission to access the requested document.” 

This error typically occurs when the email address of the account that you’re using to authorize and execute the Google Ads Script does not have write/editor access to the used spreadsheet (or another Google Drive document) in your script.

Solution:

Use the same email address to authorize and run the Google Ads Script that also has write/editor access to the used spreadsheet/document.

More details: https://nilsrooijmans.com/google-ads-scripts-faq/exception-you-do-not-have-permission-to-access-the-requested-document/ 

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,
Sep 23, 2024, 3:17:39 AM9/23/24
to adwords...@googlegroups.com

Hi,

@Nils - thanks for providing a solution to the user.

I would suggest that you go through the solution provided by Nils and get back to us if you still face any issues. 

Reply all
Reply to author
Forward
0 new messages