Is it not possible to use ads script to pause/enable Demand Gen ads?

12 views
Skip to first unread message

Ayudhia Pohan

unread,
Nov 11, 2025, 3:58:09 AM (5 days ago) Nov 11
to Google Ads Scripts Forum
I am trying to automate enabling and pausing the Demand Gen ad (not campaign, not ad group) based on a criteria that I set. The script worked to identify based on the criteria but it failed to do the actual job, which is to pause and enable the ad.

For the pause and enabling command, I tried some different approach and everything failed.

1. Direct Action (.pause()/.enable()): This failed because the script couldn't find the ad objects ("Could not find ad object").

2. Bulk Upload (Resource Name): This failed because the system accepted the job but made "No changes".

3. Bulk Upload (Ad ID): This failed because the system rejected the file with a "system error".


Is it currently not possible to use ads script to pause/enable Demand Gen ad? Thank you for your help.

This is the code for example:

// --- TEST SCRIPT ---
// This script will find ONE specific Demand Gen ad by its name and pause it.

function main() {
 
  // 1. The exact name of the ad you want to pause
  const AD_NAME_TO_PAUSE = "ad name example";

  Logger.log(`Starting test to pause ad: ${AD_NAME_TO_PAUSE}`);

  // 2. Find the ad's Resource Name using a GAQL query
  // We only want to find it if it's currently ENABLED
  const query = `
    SELECT
      ad_group_ad.resource_name,
      ad_group_ad.ad.name,
      ad_group_ad.status
    FROM ad_group_ad
    WHERE
      ad_group_ad.ad.name = "${AD_NAME_TO_PAUSE}"
      AND ad_group_ad.status = 'ENABLED'
  `;

  const report = AdsApp.search(query);
  const changesToUpload = [];

  // 3. Get the ad's resource name
  if (report.hasNext()) {
    const row = report.next();
    const resourceName = row.adGroupAd.resourceName;
   
    Logger.log(`Found enabled ad. Resource Name: ${resourceName}`);
   
    changesToUpload.push({
      resource: resourceName,
      status: "PAUSED"
    });

  } else {
    Logger.log("Ad not found. It might be already paused, removed, or the name is incorrect.");
    return; // Stop the script
  }

  // 4. Apply the change using Bulk Upload
  if (changesToUpload.length > 0) {
    Logger.log("Submitting 1 change (pause) via Bulk Upload...");

    const bulkUpload = AdsApp.bulkUploads().newCsvUpload([
      "Ad Group Ad Resource Name", "Status"
    ]);

    bulkUpload.append({
      "Ad Group Ad Resource Name": changesToUpload[0].resource,
      "Status": changesToUpload[0].status
    });

    // Apply() is LIVE mode. This actually makes the change.
    bulkUpload.apply();
   
    Logger.log("--- TEST SUCCESSFUL ---");
    Logger.log("Change has been applied. Please check the Google Ads UI in 1-2 minutes.");

  } else {
    Logger.log("--- TEST FAILED ---");
    Logger.log("Could not find the specified ad while it was 'ENABLED'.");
  }
}

Google Ads Scripts Forum Advisor

unread,
Nov 11, 2025, 4:33:20 AM (5 days ago) Nov 11
to adwords...@googlegroups.com

Hi Ayudhia,

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

Please be informed that updating Demand Gen campaigns by using Bulk Uploads is not supported in the Google Ads Scripts whereas, “Search, Display, Shopping, Video, App, Smart, Hotel” campaign types are currently supported via bulk uploads. However, you can use the AdsApp.mutate() method to pause Demand Gen Ad Group Ads. I would suggest that you use the below sample code to update a campaign status.

const campaignResult = AdsApp.mutate({
    campaignOperation: {
        update: {
            resourceName: "customers/[CUSTOMER_ID]/campaigns/[CAMPAIGN_ID]",
            status: "PAUSED"
        },
        updateMask: "status"
    }
});

Additionally, you may go through the Update documentation for reference. Kindly use the Resource Name of the Demand Gen Ad Group Ad in place of the ‘customers/[CUSTOMER_ID]/campaigns/[CAMPAIGN_ID]’ value for the key ‘resourceName’.

I hope this helps! Feel free to get back to us for any further assistance.

Thanks,
 
Google Logo Google Ads Scripts Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-11-11 09:32:49Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01vTAqb:ref" (ADR-00338962)



Reply all
Reply to author
Forward
0 new messages