This is a compilation of the most common issues raised in the
Google Ads scripts forum
.
Common JavaScript errors
Script is failing with "Cannot find function: FUNCTION_NAME"
This is usually the result of a misspelled function name in the script.
Check that the function name is spelled correctly and has the correct
spelling case; e.g.,
AdsApp.keywordz()
will result in this error, because
keywordz
is not a valid function in the
AdsApp
class.
AdsApp.Keywords()
will also fail due to incorrect spelling case for the
keywords()
function.
Check that the function exists; e.g.,
AdsApp.keywords().next()
will fail
because
AdsApp.keywords()
returns a
KeywordSelector
while
next()
is a method for a
KeywordIterator
object
.
The correct code would be
AdsApp.keywords().get().next()
.
My script runs, but doesn't do anything
The most common reason for this issue is that you have a function that performs
an operation, but you are not calling it from the
main()
method. This
commonly happens when you copy-paste
code
snippets
from our documentation.
Coding approach
|
Code snippet
|
Version 1 (doesn't work)
|
function main() {
// Call to getAllCampaigns is missing, so this script does nothing.
}
function getAllCampaigns() {
// AdsApp.campaigns() will return all campaigns that are not
// removed by default.
let campaignIterator = AdsApp.campaigns().get();
console.log('Total campaigns found : ' +
campaignIterator.totalNumEntities());
while (campaignIterator.hasNext()) {
let campaign = campaignIterator.next();
console.log(campaign.getName());
}
}
|
Version 2 (doesn't work)
|
function main() {
// Call to getAllCampaigns is missing, so this script does nothing.
function getAllCampaigns() {
// AdsApp.campaigns() will return all campaigns that are not
// removed by default.
let campaignIterator = AdsApp.campaigns().get();
console.log('Total campaigns found : ' +
campaignIterator.totalNumEntities());
while (campaignIterator.hasNext()) {
let campaign = campaignIterator.next();
console.log(campaign.getName());
}
}
}
|
Version 3 (works)
|
function main() {
getAllCampaigns();
}
function getAllCampaigns() {
// AdsApp.campaigns() will return all campaigns that are not removed
// by default.
let campaignIterator = AdsApp.campaigns().get();
console.log('Total campaigns found : ' +
campaignIterator.totalNumEntities());
while (campaignIterator.hasNext()) {
let campaign = campaignIterator.next();
Logger.log(campaign.getName());
}
}
|
I get a "Cannot find function getFinalUrl" error when upgrading my scripts
You may run into this error when changing your script to work with
Upgraded
URLs
. This happens when you
replace calls to
ad.getDestinationUrl()
with
ad.getFinalUrl()
.
getFinalUrl()
is part of the
AdUrls
class,
so you'd need to change your code to
ad.urls().getFinalUrl()
:
function main() {
// Incorrect snippet. getFinalUrl is not a member of the Ad class.
let ad = AdsApp.ads().get().next();
let url = ad.getFinalUrl();
// Correct snippet.
let ad = AdsApp.ads().get().next();
let url = ad.urls().getFinalUrl();
}
I get no stats for X
Unavailability of data for a particular entity or date range is a common error
you may encounter when running reports or making stats calls. There are several
things that you can try:
Check the date range for which you are retrieving stats or running reports.
If you retrieve account-level stats for an Ads Manager script that manages
accounts of different currencies, you get back the cost in the currency of
the manager account.
Google Ads may not have the data you are looking for yet. See our
data
freshness guide
for
details.
Feature requests
Is Feature X available?
Check our
reference
documentation
.
When will feature X be available?
We try to work on the most-requested features first. If there's a feature you'd
like to see, then follow these steps:
First, verify that the feature is not supported in Google Ads scripts by
checking the
reference
documentation
.
If it's not available, search the
Google Ads scripts
forum
to see if it's
already been asked about before. If yes, upvote that thread, or leave a
comment if you want to share additional details like a use case.
If the feature is not yet requested, then make a feature request by opening
a new thread on the
Google Ads scripts
forum
. Make sure you
provide a use case that this feature will solve. When possible, include a
link to the Help Center guide or an AdWords API blog post / guide that
describes this feature. This will help other developers as they upvote a
feature request. We prioritize feature requests based on their popularity.
Tag the post as "Feature Request" to make it easier for us (as well as
users) to quickly check for feature requests.
How do I use feature X?
See our
code snippets
and
solutions
for examples of how to
use a particular feature. If you don't find a suitable code snippet, feel free
to make a request in the forum.