Script to pause adgroups that contains XYZ present in a GSheet

36 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Martha Landesman

ungelesen,
22.06.2022, 08:30:3322.06.22
an Google Ads Scripts Forum
Hello everyone
I am looking for a script that would run to pause all adgroups that contain a certain information (an ID, not the adgroup ID but an ID that we input in the adgroup name) present in a Google Sheet under a tab (1 ID per line)
Would you be able to help find the right script to do so?
Thanks!
Martha

Google Ads Scripts Forum Advisor

ungelesen,
23.06.2022, 02:51:3123.06.22
an adwords...@googlegroups.com
Hi Martha,

Thank you for reaching out to us.

Could you please elaborate what you mean by id that you put on the name? An example of this would be greatly help us to provide precise guidance to your concern.

Regards,
Google Logo
Teejay Wennie
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bz2E3:ref

Martha Landesman

ungelesen,
27.06.2022, 10:32:0827.06.22
an Google Ads Scripts Forum on behalf of adsscripts
Hello

For instance, a line is >947056080039 and I would like the script to go and pause the adgroups that contain >947056080039

Looking forward fo your answer
Thanks

--
-- 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/V8wCWgJtoYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-scripts/yImg4000000000000000000000000000000000000000000000RDX4DN00g9hShCZpTDqE3regq4tqOA%40sfdc.net.


--

Martha Landesman

Digital Marketing Manager M: +33 6 70 59 38 18

Google Ads Scripts Forum Advisor

ungelesen,
28.06.2022, 02:55:3128.06.22
an adwords...@googlegroups.com
Hello,

Thank you for providing the requested information. 

With regard to your concern, you will need to consider the following when creating the script
  • Utilized the App Scripts SpreadsheetApp to iterate each rows of your sheet
  • Create an AdGroup selector with .withCondition("ad_group.name LIKE'" + searchId + "'") added condition
  • Inside of your iterator, use the pause() method to pause the specific adgroup
With the information mentioned above, I've created a simple script for you. Please see snippet code below.
 
function main() {
  
  var spreadsheet = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1GZ6gyubXMHVb9vuIXku8Tb40OfFuJcuynCbJ8U22jCE/edit#gid=0');
    
    //
    var sheet = spreadsheet.getSheetByName('Sheet1');
    var startRow=2;
    var rg= sheet.getDataRange();
    var vA=rg.getValues();

    for(var i=1;i<vA.length;i++) {
      
      var searchId = vA[i][0];
      
      console.log("Seaching Adgroupd with " + searchId);
      
      var adGroupSelector = AdsApp
        .adGroups()
        .withCondition("ad_group.name LIKE'" + searchId + "'")
      ;

      var adGroupIterator = adGroupSelector.get();
      while (adGroupIterator.hasNext()) {
        var adGroup = adGroupIterator.next();
        
        Logger.log("Pausing AdGroup: " + adGroup.getName());
        adGroup.pause();
      }

      
      
    }
  
}

Martha Landesman

ungelesen,
30.06.2022, 07:42:1430.06.22
an Google Ads Scripts Forum on behalf of adsscripts
Hi Teejay

Thanks for your help ! I implemented the script but it doesn"t seem to work as when I do a preview it is not pausing any adgroups, while when I search directly in the accounts, I see around 1800 adgroups to be paused. 
Do I need to implement the script at MCC level (preferred option as the adgroups to be paused are in different accounts) or at account level ?
Is there an error, a typo in the script you've sent?
For instance, I don't see the LIKE function in the script documentation about AdGroup selector 

Thanks in advance for your help
Martha

--
-- 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/V8wCWgJtoYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.

Google Ads Scripts Forum Advisor

ungelesen,
01.07.2022, 02:49:5101.07.22
an adwords...@googlegroups.com

Hello Martha,

I’m James, a colleague of Teejay. Allow me to assist you further.

You mentioned that the script doesn’t seem to work when you do a preview. By mentioning the term preview, are you pertaining to the preview mode of the Google Ads scripts? I asked this because if the script has been executed in preview mode, they make no changes to the actual ad group data. Instead, script execution shows the changes that would have been made had the script been executing. However, I misunderstood your concern, then can you please provide more context with the issue you encounter while previewing along with your CID and script so that we can re-assess further?

As per checking with the given script, I believe that this should be implemented at account level because I observed that its code construction is only applicable at account level.

Regarding your last question, I don’t see any typographical errors within the given script. For the given instance, LIKE operator is supported as per our documentation.

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2bz2E3:ref

Peter Valenta

ungelesen,
01.07.2022, 03:03:0101.07.22
an Google Ads Scripts Forum
Shouldnt there be % signs in the LIKE clause value?

.withCondition("ad_group.name LIKE'%" + searchId + "%'")

Martha Landesman

ungelesen,
01.07.2022, 03:29:3501.07.22
an Peter Valenta via Google Ads Scripts Forum
Hi both, 

Thanks for reaching out! I have asked help from a data scientist in my team and he was able to make the script working.

Thanks for your help
Have a nice day

Martha

--
-- 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/V8wCWgJtoYs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to adwords-scrip...@googlegroups.com.
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten