google app script can't add Google Ads API service

118 views
Skip to first unread message

Clayton Laramie

unread,
May 21, 2025, 9:03:19 PM5/21/25
to Google Ads Scripts Forum
Hi there,

Trying to write a google app script that pushes website exclusions from Google Sheets to Google Ads placement exclusions list. Gemini wrote the code. The error log says: 

ReferenceError: AdsApp is not defined. Skipping this account.

Gemini told me to add Google Ads API as a service to the app script project, but Google Ads API isn't in the list. There's nothing with Google Ads in the Services list. I checked Wrokspace admin console and logged a ticket with them but Gemini is adamant that the problem is within App Script not being able to access the Service.

Below is the code that should be defining AdsApp and MccApp

// Process each customer ID
  for (const customerId in placementsByCustomerAndList) {
    Logger.log(`Processing Customer ID: ${customerId}`);
    try {
      const MccApp = AdsApp; // In single account context, AdsApp is used. If under MCC, MccApp might be relevant.
                            // For selecting specific accounts, AdsApp.accounts().withIds() is the way.
      const accounts = MccApp.accounts().withIds([customerId]).get();
      if (accounts.hasNext()) {

Anyone know how to resolve this?

Google Ads Scripts Forum

unread,
May 22, 2025, 12:42:13 AM5/22/25
to Google Ads Scripts Forum
Hi,

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

I would like to inform you that the MccApp is now replaced with "AdsManagerApp" as per the Google Ads Scripts documentation. You can refer to sample example documentation to fetch the account details associated with the manager account. If you want to fetch the details for a single account, you can refer to this example on using AdsApp method. Regarding the placement exclusion lists, I would suggest you to refer the available methods of ExcludedPlacementList and the corresponding sample examples.

Feel free to get back in case of any further issues by providing us the following:
  • Google Ads account ID/CID
  • Name of the script
You can share the requested details via Reply privately to the author option or a direct private reply to this email.

Thanks,
Google Ads Scripts team

Clayton Laramie

unread,
May 22, 2025, 9:15:32 AM5/22/25
to Google Ads Scripts Forum
Thanks so much for your reply. This worked when updating the script within Google Ads Scripting interface. However, if we try to write the script within Google Sheets as an App Script, it fails. Gemini keeps saying we must add Google Ads API as a service within the App Script project, but Google Ads API isn't available in the list. Do you happen to know if Gemini is just wrong about this or if there's something we have to do to get Google Ads API service to appear in Google App Scripts? FWIW, within Workspace Admin console, all Google services are ON and we have max privileges.

Clayton Laramie
Owner & Founder



--
-- You received this message because you are subscribed to the Google Groups AdWords Scripts Forum group. Please do not reply to this email. To post to this group or unsubscribe please visit https://developers.google.com/adwords/scripts/community.
---
You received this message because you are subscribed to a topic in the Google Groups "Google Ads Scripts Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/adwords-scripts/t1hYFtS4scU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/adwords-scripts/0c9b8fb6-5c20-45a3-84b5-c394ce8b80fbn%40googlegroups.com.

Google Ads Scripts Forum Advisor

unread,
May 22, 2025, 12:52:49 PM5/22/25
to adwords...@googlegroups.com
Hi Clayton,

Note that concern related to Google Apps script and Gemini are out of scope for Google Ads Scripts team, as we can only provide assistance with technical issues or concerns related to the Google Ads scripts.

Regarding the failure of your script within Google Sheets App Script, I recommend contacting the Google Apps Script support directly, as they have the expertise to assist you with this.

For your concerns related to Gemini, you may reach out to the Gemini Support team via this link.  

Thanks,
 
Google Logo Google Ads Scripts Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-05-22 16:52:16Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01qXuvp:ref" (ADR-00307548)



Reply all
Reply to author
Forward
0 new messages