Tuesday, November 21, 2023
HomeTechnologyAdWords script to turn off phone extensions for holidays!

AdWords script to turn off phone extensions for holidays!

Are you using the phone number display option? With this phone number display option, if it is left as default, it is possible to switch between display and non-display for each day of the week and hour, but it is possible to automatically switch between display and non-display for holidays and irregular holidays. you can’t. So even if it’s a holiday and you’re not ready to receive calls, call extensions are often left on.

If a search user is interested and calls you, but the phone line is cut off, the user’s convenience will be greatly reduced. Therefore, I will introduce an AdWords script to automatically turn off the phone number display option when you can not receive calls that come irregularly, such as holidays.


In addition, this time, assuming an advertiser who conducts business in B2B format, we will consider the case of turning off the ad display option on Saturdays, Sundays, and holidays according to the calendar.

Script prerequisites

Several prerequisites must be met before the script can run. However, the conditions are not that high of a hurdle, so don’t worry.

The control in the normal period is switched with the default function

AdWords has a function that allows you to automatically switch between displaying and hiding phone number display options for each day of the week and hour. This time, we assume that you will turn off the ad display options on weekends and holidays as per the calendar, so please set the ad control on Saturdays and Sundays with the default function of AdWords.

Also, use the default settings to turn on call extensions during business hours only and turn off call extensions for early mornings and late nights.

All holiday information must be managed in one Google calendar

In this AdWords script, we don’t keep holiday data in the script, but use the same Google service, Google Calendar. AdWords Script was originally a part of Google Apps Script, and Google Calendar also implements Google Apps Script API, so it is easy to operate the data on Google Calendar from AdWords Script.

Also, if you use the same calendar as Japanese holidays , you can solve it by using Japanese holidays , which is the default holiday calendar provided by Google Calendar . If it does not match the holiday exactly according to the calendar, it is necessary to create a Google calendar and register the holiday information there.

The target campaign for setting the phone number display option must be all campaigns.

In order to keep the AdWords script as simple as possible, we do not provide an interface for separately specifying campaigns for which call extensions should be set. Call extensions are automatically set for all campaigns registered in your account. If for some reason you don’t want to use the phone number display option for a specific campaign, you can’t use the AdWords script introduced here. Don’t worry, though, you’ll only have to fix a few things.

All registered phone numbers must be valid

Again, this is a constraint to keep AdWords scripts as simple as possible. If a phone number has been registered as valid for use with call extensions, the AdWords script will irrespective of all calls, even if “a phone number is not associated with any campaigns” at the initial point. Associate a number with all campaigns. If you want to register a phone number that you can no longer use to your account, let’s delete it.

AdWords script preparation

The Google Calendar API is categorized as an Advanced API on AdWords scripts, and some preparation is required to use it.

Pre-preparation

  • Enable Google Calendar API in AdWords Script
  • Register with Google Developer Console (if not registered)
  • Enable the Google Calendar API for the project on the Developer Console linked to your AdWords script

3 points.

Enable Google Calendar API in AdWords Script

After pressing the Create AdWords script button, click the API (advanced) button from the buttons at the top of the displayed editor .

Next, check the checkbox of Calendar from the window that pops up .

This completes the API usage settings on the AdWords script side.

Enable Google Calendar API on Developer Console

Click the API (advanced) button you clicked earlier, and this time go to the Google Developers Console from the link in this window.

From this screen, specify the APIs you want to enable in your AdWords script. We need the Calendar API here, so find Calendar API, click the link, and click the Enable API button to enable the Calendar API .

Introduction to AdWords scripts

Now let’s take a look at our AdWords script. At the beginning of the script, there is a place to specify the ID of the Google Calendar to be used, so please change this to your own calendar ID. is not).

var CALENDAR_ID = 'ja.japanese#holiday@group.v.calendar.google.com';

function main() {
  setPhoneNumberExtension( (isHoliday() ? '表示しない' : '表示する') );
}

function isHoliday() {
  var events = Calendar.Events.list(CALENDAR_ID, {
    timeMin: (new Date()).toISOString(),
    singleEvents: true,
    orderBy: 'startTime',
    maxResults: 1
  }).items;

  if (events.length >= 1) {
    var start = events[0].start.date;
    return ((new Date()).toISOString().substr(0, 10) == start);
  } else {
    return false;
  }
}

function setPhoneNumberExtension(settingValue) {
  if (settingValue == '表示する') {
    Logger.log('全てのキャンペーンに対し, 全ての電話番号表示オプションの関連付けを設定します');
    enablePhoneNumberExtension();
  } else if (settingValue == '表示しない') {
    Logger.log('全てのキャンペーンから, 全ての電話番号表示オプションの関連付けを削除します');
    disablePhoneNumberExtension();
  }
}

function disablePhoneNumberExtension() {
  var campaigns = AdWordsApp.campaigns().get();
  while (campaigns.hasNext()) {
    var campaign = campaigns.next();
    var phoneNumbers = campaign.extensions().phoneNumbers().get();
    while (phoneNumbers.hasNext()) {
      var phoneNumber = phoneNumbers.next();
      campaign.removePhoneNumber(phoneNumber);
    }
  }
}

function enablePhoneNumberExtension() {
  var campaigns = AdWordsApp.campaigns().get();
  while (campaigns.hasNext()) {
    var campaign = campaigns.next();
    var phoneNumbers = AdWordsApp.extensions().phoneNumbers().get();
    while (phoneNumbers.hasNext()) {
      var phoneNumber = phoneNumbers.next();
      campaign.addPhoneNumber(phoneNumber);
    }
  }
}

summary

Even if you just use the ad display option, it will be a very powerful weapon that can be expected to improve your quality score. It will be wasted and will be taken over by other competitors. To prevent this from happening, try to ensure usability by turning off the phone number display option when you are not available to answer calls. prize.

RELATED ARTICLES

What is StyleGAN?

Leave a reply

Please enter your comment!
Please enter your name here

Recent Posts

Popular Posts

Most Popular

Recent Comments