This is the legacy documentation for Google Ads scripts. Go to the current docs.


Stay organized with collections Save and categorize content based on your preferences.

Post a message to a user or group

 * An example of sending messages into Slack. See:
 * Webhook set up at: >
 * 'Set up an incoming webhook', follow the steps then click 'Add Incoming
 * WebHooks Integration'. This will create the URL needed for below, e.g:
 * '';

// An example of retrieving an Google Ads Report and sending it in a slack message.
function sendReportToSlack() {
  var report =
      'SELECT CampaignName, Impressions, Clicks FROM ' +
  var spreadsheet = SpreadsheetApp.create('Report');

  // See for message formatting.
  var message = 'Your *Google Ads Report* is ready! <' + spreadsheet.getUrl() +
      '|Click here>';

 * Sends a message to Slack
 * @param {string} text The message to send in slack formatting. See:
 * @param {string=} opt_channel An optional channel, which can be channel e.g.
 *     '#google-ads' or a direct message e.g. '@sundar'. Defaults to '#general'.
function sendSlackMessage(text, opt_channel) {
  var slackMessage = {
    text: text,
    username: 'Google Ads Scripts',
    channel: opt_channel || '#general'

  var options = {
    method: 'POST',
    contentType: 'application/json',
    payload: JSON.stringify(slackMessage)
  UrlFetchApp.fetch(SLACK_URL, options);