Import a specific Google Sheet into Google Ads

79 views
Skip to first unread message

Mathieu Tao

unread,
Aug 26, 2019, 9:15:26 AM8/26/19
to Google Ads Scripts Forum
Hello everyone,

I can't figure out how to retrieve a specific Google Sheet and import it into google Ads.
Example :
In a spreadsheet, I have 3 sheets, I would like to import only sheet 2 into Google Ads.
How do I do this?

Thank you in advance

Nathan Alfa

unread,
Aug 26, 2019, 9:20:11 AM8/26/19
to Google Ads Scripts Forum
Hello, 
I know it's easy to link Google Ads to google SpreadSheets 
But to do the opposite I think it's much more complicated,
and the only script I know that makes Google SpreadSheet communicate to Google Ads, 
it's the Link Checker script from google.

Nathan Alfa

Sigurd

unread,
Aug 26, 2019, 10:07:07 AM8/26/19
to Google Ads Scripts Forum
Not sure what is meant by 'import'.

Here's how you can select a specific sheet
var url = 'REPLACE WITH URL OF SPREADSHEET';
var sheetName = 'REPLACE WITH NAME OF SHEET';
var ss = SpreadsheetApp.openByUrl(url);
var sheet = ss.getSheetByName(sheetName);
 
 sigurd

Mathieu Tao

unread,
Aug 26, 2019, 11:51:09 AM8/26/19
to Google Ads Scripts Forum
My sheet contains keywords to exclude for each campaign in my account. What I would like to do is import this sheet into google Ads to exclude these keywords.
Once I have selected my sheet how do I send it to google ads?

Google Ads Scripts Forum Advisor Prod

unread,
Aug 26, 2019, 1:55:52 PM8/26/19
to adwords-scripts+apn2wqevinbbivog...@googlegroups.com, adwords...@googlegroups.com
Hi All,

You can reference a sheet in the way mentioned above. You can get values from cells and set values using the SpreadsheetApp service. Here are number spreadsheet app code snippets.

If you want to retrieve string values (that may represent keywords, for example) from a spreadsheet range, you can get the getValues function to store them in a two dimensional array. For example,

// The code below gets the values for the range C2:G8
// in the active spreadsheet.  Note that this is a JavaScript array.
var values = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getValues();

Regards,
Matt
Google Ads Scripts Team 

ref:_00D1U1174p._5001UHEf1K:ref

Mathieu Tao

unread,
Aug 28, 2019, 11:20:58 AM8/28/19
to Google Ads Scripts Forum
thank you for this information!
Now that I have retrieved my words to exclude, I would like to add them to a specific adgroup.
I looked at the site (https://developers.google.com/google-ads/scripts/docs/examples/negative-keywords#get-negative-keywords-in-an-ad-group) to help me but I think there is something wrong with what I do.
When I do the test, I see the keyword neither on the console (it puts me "undefined") nor in the section "Keywords to exclude".
below my script :

// Selection de la campagne dans Ads
   var campaignName = "G|SRC|FR|Brand";
   var campaignsIterator = AdsApp.campaigns().withCondition("Name = '" + campaignName + "'").get();
   var campaignAds =  campaignsIterator.next();
   Logger.log("Campagne : "+campaignAds);
  
  //-------------------------------------------------------------//
  // Selection de l'adgroup de la campagne
 var adgroupName ="dk test";
  var adgroupIterator = campaignAds.adGroups().withCondition("Name = '" +adgroupName+"'").get();
  var adgroupAds = adgroupIterator.next();
  Logger.log("Adgroup : "+adgroupAds);
  
    //-------------------------------------------------------------//
  // insérer un MC en negatif exact dans la campagne

 
  Logger.log("test1 :  "+adgroupAds.createNegativeKeyword('[test]'));

Regards,
Mathieu

Google Ads Scripts Forum Advisor Prod

unread,
Aug 28, 2019, 6:49:31 PM8/28/19
to adwords-scripts+apn2wqcfiln-vyyw...@googlegroups.com, adwords-scripts+apn2wqcfiln-vyyw...@googlegroups.co, adwords...@googlegroups.com
Hi Mathieu,

I think I need to see your full script because the variable, test from:


  Logger.log("test1 :  "+adgroupAds.createNegativeKeyword('[test]'));

Is not shown in the script. 

Keep in mind that simply pulling text from a spreadsheet will not be recognized as a keyword from Ads scripts. 

I recommend looking at these negative keyword and spreadsheet samples.
Reply all
Reply to author
Forward
0 new messages