This is a compilation of common issues raised by Google Ads scripts developers.

> [!NOTE]
> **Note:** This page only lists general questions related to scripts. If your question is specific to a [solution](https://developers.google.com/google-ads/scripts/docs/solutions), refer to the corresponding solutions page.

## Common JavaScript errors

Here are some common JavaScript errors.

### Script fails with "Cannot find function: FUNCTION_NAME"

This is usually the result of a misspelled function name in the script.

1. Check that the function name is spelled correctly and has the correct
   spelling case; for example, `AdsApp.keywordz()` will result in this error,
   because `keywordz` is not a valid function in the
   [AdsApp](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp) class.
   `AdsApp.Keywords()` will also fail due to incorrect spelling case for the
   `keywords()` function.

2. Check that the function exists; for example, `AdsApp.keywords().next()`
   will fail because
   [`AdsApp.keywords()`](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp#keywords)
   returns a
   [`KeywordSelector`](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_keywordselector)
   while `next()` is a method for a [`KeywordIterator` object](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_keyworditerator).
   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](https://developers.google.com/google-ads/scripts/docs/examples)
from our documentation.

| Coding approach | Code snippet |
|---|---|
| **Version 1 (doesn't work)** | ``` function main() { // Call to getCampaigns is missing, so this script does nothing. } function getCampaigns() { // AdsApp.campaigns() will return all Search and Display 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 getCampaigns is missing, so this script does nothing. function getCampaigns() { // AdsApp.campaigns() will return all Search and Display 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() { getCampaigns(); } function getCampaigns() { // AdsApp.campaigns() will return all Search and Display 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](https://support.google.com/google-ads/answer/6049217). This happens
when you replace calls to `ad.getDestinationUrl()` with `ad.getFinalUrl()`.
`getFinalUrl()` is part of the
[AdUrls](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_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:

1. Check the date range for which you are retrieving stats or running reports.

2. 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.

3. Google Ads may not have the data you are looking for yet. See our
   [data freshness guide](https://support.google.com/google-ads/answer/2544985) for
   details.

### How do I use feature X?

See our [code snippets](https://developers.google.com/google-ads/scripts/docs/examples) and
[solutions](https://developers.google.com/google-ads/scripts/docs/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 [discord](https://goo.gle/google-ads-discord).

### Still need support?

If you need assistance with an area where we can help, visit the [Get
Help](https://developers.google.com/google-ads/scripts/docs/support/get-help) page.