Ad Performance Report Script

470 views
Skip to first unread message

Matthew Seldon

unread,
May 25, 2022, 9:32:00 AM5/25/22
to Google Ads Scripts Forum
I'm using the script from this page: https://developers.google.com/google-ads/scripts/docs/solutions/ad-performance and have got it to work but everytime the script is run it creates the data in a new sheet. 
Is it possible instead to overwrite the data in my existing sheet? If so what changes would be needed to the script.
Hoping you can help! Thanks.

Google Ads Scripts Forum Advisor

unread,
May 27, 2022, 2:27:50 AM5/27/22
to adwords...@googlegroups.com
Hi Matthew,

Thank you for reaching out to us.

With regard to your concern, I'm afraid that the Ad Performance Report solution script is built to create the data in a new sheet. You may use the clearContent() method to clear the sheet's content at the start of the main function.

Regards,
Google Logo
Teejay Wennie
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bDNMR:ref

Matthew Seldon

unread,
May 27, 2022, 3:58:57 AM5/27/22
to Google Ads Scripts Forum
Hi Teejay,

I've tried adding the code in red (below) at the start of "main()" but get an error - TypeError: Cannot read property 'getSheets' of null . I'm no coder so I know I've messed this up and hope you can help further :) but I can guess that unless I also remove some additional code it won't stop a new sheet being created either.

function main() {
 
console.log(`Using template spreadsheet - ${SPREADSHEET_URL}.`);
  const spreadsheet = copySpreadsheet(SPREADSHEET_URL);
  console.log(`Generated new reporting spreadsheet ${spreadsheet.getUrl()} ` +
      `based on the template spreadsheet. ` +
      `The reporting data will be populated here.`);
 
  var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var range = sheet.getRange("A1:D10");
range.clearContent();


Google Ads Scripts Forum Advisor

unread,
May 30, 2022, 1:07:44 AM5/30/22
to adwords...@googlegroups.com

Hello Matthew,

I’m James, also a member of the Google Ads scripts support team. Allow me to assist you further.

Can you please provide us with the following details below so that we can further check and guide you accordingly?

  • Google Ads account ID / CID
  • Name of the involved script

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bDNMR:ref

Matthew Seldon

unread,
May 30, 2022, 3:34:27 AM5/30/22
to Google Ads Scripts Forum
Hey James,

Here are the details:
752-549-4603
Ad Performance Report - Hourly

Apprechiate any help!
Thanks.

Google Ads Scripts Forum Advisor

unread,
May 31, 2022, 11:19:58 PM5/31/22
to adwords...@googlegroups.com

Hello Matthew,

Thank you for providing the requested information. I made some adjustments to your script in order for it to overwrite data in an existing spreadsheet. That said, can you please try to implement the attached script below and let me know how it goes on your end?

Regards,

Google Ads Scripts Forum Advisor

unread,
May 31, 2022, 11:20:34 PM5/31/22
to adwords...@googlegroups.com
Ad performance script - modified.txt

Matthew Seldon

unread,
Jun 1, 2022, 3:00:29 AM6/1/22
to Google Ads Scripts Forum
Amazing, it works perfectly, thanks so much for your help James!

Google Ads Scripts Forum Advisor

unread,
Jun 2, 2022, 1:53:12 AM6/2/22
to adwords...@googlegroups.com

Hello Matthew,

I’m glad that it works perfectly on your end. If you need anything else from us, please let us know. We’re here to assist you.

Regards,

Matthew Seldon

unread,
Jun 6, 2022, 4:48:36 AM6/6/22
to Google Ads Scripts Forum
One more quick question!
How do I stop the emails getting sent to myself everytime the script runs?

// Array of recipient emails. Comment out to not send any emails.
    'recipient_emails': [''],

I've tried leaving the field blank as above but I get a script error when doing it this way.

Google Ads Scripts Forum Advisor

unread,
Jun 6, 2022, 10:00:30 AM6/6/22
to adwords...@googlegroups.com
Hi Matthew,

Please comment out the recipient_emails line:


    // Array of recipient emails. Comment out to not send any emails.
    // 'recipient_emails': ['INSERT_EMAIL_HERE'],
    // URL of the default spreadsheet template. This should be a copy of

The '//' denotes a comment, so that line will be ignored on execution.

Regards,

Google Logo
Matt
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bDNMR:ref

Matthew Seldon

unread,
Jun 7, 2022, 3:41:24 AM6/7/22
to Google Ads Scripts Forum
Hey guys,

Hoping for a little more help here as I've just realised with this new update to the script as I'm using the same sheet each when the script reruns it doesn't clear rown further down if they are no longer used.
Is there a way to update the script so that each time it runs it clears the dynamic rows (rows populated with data from Google) on the tab "Final URL" before repopulating?

Google Ads Scripts Forum Advisor

unread,
Jun 8, 2022, 1:29:20 AM6/8/22
to adwords...@googlegroups.com

Hello Matthew,

Thank you for getting back to us.

I believe that you can use the clearContent() method to clear the data of a specific rows in your sheet. Can you please try to implement the said method and let me know how it goes on your end?

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bDNMR:ref

Matthew Seldon

unread,
Jun 8, 2022, 3:13:56 AM6/8/22
to Google Ads Scripts Forum
Perfect! Got it working, thank you :D

Google Ads Scripts Forum Advisor

unread,
Jun 8, 2022, 4:03:19 AM6/8/22
to adwords...@googlegroups.com

Hi Matthew,
 

Thank you for the update.
 

Our team is happy to hear that. If you have further questions / concerns for our team, please feel free to get back to us. We will be happy to address it.


Regards,

Google Logo
Darwin
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bDNMR:ref
Reply all
Reply to author
Forward
0 new messages