Here’s why you get “Invalid argument: url (file Code.gs, line XX)” errors

ERROR: “Invalid argument: url (file Code.gs, line XX)” 

This error typically occurs when you copy-paste a third party Google Ads script, like for instance the Link Checker solution from Google, and then add the URL for your own spreadsheet to the script configuration.

 

When you simply replace

var SPREADSHEET_URL = 'YOUR_SPREADSHEET_URL';

with something like

var SPREADSHEET_URL = 'https://docs.google.com/spreadsheets/d/42g2D8t2AmHDD6fs6y__kLG80fa_4aeoeLjjiQrwXXXX';

This is the error that will show up in the log:

Invalid argument: url (file Code.gs, line XX)

And line XX could say something like this:

this.spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);

 

Solution:

You might think you need to change the sharing settings of the Google Sheet to public (so that the script can access the sheet), however, this is not the case.
It’s far easier and less logical than that:

The Google spreadsheet URL must be completed with a slash.

Simply add the slash and you’re good to go:

var SPREADSHEET_URL = 'https://docs.google.com/spreadsheets/d/42g2D8t2AmHDD6fs6y__kLG80fa_4aeoeLjjiQrwXXXX';

->

var SPREADSHEET_URL = 'https://docs.google.com/spreadsheets/d/42g2D8t2AmHDD6fs6y__kLG80fa_4aeoeLjjiQrwXXXX/';

 

"Damn, your blog is full of great info. I like your compilation of scripts, very handy!"

E.C., PPC geek at Reddit

Nils Rooijmans
2020-08-16T10:58:27+00:00

E.C., PPC geek at Reddit

"Damn, your blog is full of great info. I like your compilation of scripts, very handy!"
0
0
Nils Rooijmans

Would you like to join thousands of PPC geeks who already have access?

If the button above isn’t working for you, you can sign up here to get access.