Facebook Pixel Code

Want a head start in making the shift to expanded text ads in AdWords? Columnist Frederick Vallaeys has an AdWords script that pulls information from your SEO titles and meta descriptions.

Just about a week ago, all AdWords advertisers got access to expanded text ads. Have you converted your whole account over to take advantage of the new format yet?

If you haven’t because you’ve been too busy with the day-to-day of managing accounts (or because you took that well-earned summer vacation), read on for an easy to use AdWords Script that can help.

The concept

The goal is to leverage all the work already done by your SEO team to give the PPC team a head start with creating longer text ads. After all, the recommended lengths for SEO titles and descriptions are pretty close to the new limits Google allows for expanded text ads.

While it’s very hard to fully automate the creation of ads, the goal of the script is to give advertisers a starting point that is better than their existing ads or worse, a blank bulksheet. Depending on how your SEO tags are set up, it’s possible that the script will produce acceptable results right out of the box.

Leveraging existing script code

The script is a simple adaptation of one of the oldest scripts out there: the broken URL checker. Instead of fetching landing pages to see if they return errors, I modified the code to fetch the metatags of the page, specifically the title, description and first h1 tag of each page that is used as a landing page by an existing ad.

I’ve said it before, and I’ll say it again, but the beauty of AdWords Scripts is that they are easy to modify. If you also had the idea to use metadata to construct expanded text ads, you could have grabbed an existing code sample and with some small tweaks, adapted it to complete this task.

I know the majority of readers don’t write code, though, so you can simply copy and paste a fully working version below.

Turning the title tag into headline ad text

The recommended length for the title tag is 50 to 60 characters, according to Moz. Google allows 30 characters each for headline 1 and headline 2, for a total of 60 characters. Beware, though, that titles that exceed a certain pixel count may get truncated, and, according to Google, titles that are 33 characters or shorter are the least likely to be truncated.

The script fetches the title and splits it into two lines of up to 30 characters each. In case this truncates your original title tag, we’ve included it in the spreadsheet so you can reference it while you rewrite your headlines.

I’ve also added an optional setting to specify how long you want your overall title to be so if you would like to stay within 33 characters because you’re in a vertical where there are strict regulations about ad text, then this is a good option for you.

The setting is called “maxHeadlineLength,” and you can set the value to “33,” some other number, or leave it at “60” to use the full allowed length. Do keep in mind that many headlines will be shorter than 60 characters even when you are allowing the script to use all characters. This is because we have to split the title between two lines, so we look for the first word break before the end of the line.

Turning the description tag into the ad description

If our SEO colleagues stuck to Moz’s recommendation for a description tag length, our landing pages should have a description between 150 and 160 characters in length. That’s twice as long as the 80 characters Google now allows us to include in expanded text ad descriptions.

The script pulls the description tag in its entirety and truncates it at the last full word before 80 characters. So once again, you can refer to the original description if you need to rewrite what the script suggested for the starting point.

There are no more mobile preferred ads

While the announcement and eventual launch of expanded text ads got quite a bit of media attention, the removal of a mobile preferred ad hasn’t garnered quite the same attention. So if you haven’t played with the new format at all, when you do, you will see that there is no difference between expanded text ads for different devices. The only difference is that advertisers get to set an optional mobile final URL.

My script fetches both the old regular final URL and that of the mobile preferred ad. When it generates the bulksheet, it combines the two together on a single line so that you can write a single new ad that will have both the mobile and regular final URL.

The metadata is only fetched from the regular landing page, so if you use different metatags on your mobile site, you’d have to edit the code to start fetching those.

The script’s output

When the script finishes, it will have created a Google Sheet in your Google Drive named “Expanded Text Ads From Meta Data (Your_Account_Name).”

As I mentioned, this automation is intended to give you a head start on creating new ads but it will not be perfect, so you can edit our baseline suggestions in your favorite spreadsheet tool; then, copy and paste it all into the newest version of the AdWords Editor, where you can make final tweaks and upload it to the account.

The results of expanded text ads

It’s too early for me to share findings of how expanded text ads have performed for us but Merkle RKG has announced some mixed preliminary results. This is not to say that you should stay away from expanded text ads. Getting your own experiments up-and-running is an important first step in being able to A/B test the results.

I recommend that you launch expanded text ads for all your ad groups as soon as possible but leave regular ads running just in case those still perform better. Advertisers will still be able to create legacy ads until October 26, 2016.

The script

Here’s the AdWords Script that you can copy and paste into AdWords. As you run it, keep a few things in mind:

  1. AdWords Scripts can only run for up to 30 minutes. If you have too many unique final URLs, the script may time out before it is able to process all of them. If this happens, you can update the query we use to fetch ads to only include a subset of all your campaigns.
  2. The script uses the UrlFetch() function, and this has a Google-imposed daily limit of fetching a maximum of 20k to 100k URLs and 100 Mb of data (depending on your version of Google Apps). If you need more quota, you could split the script by campaign and then wait a day to start on the next one.


I’m excited to see the launch of the first of many announced new capabilities for AdWords. Google is strategically launching this in the dog days of summer to minimize any possible disruption to advertisers, but that doesn’t mean you shouldn’t start converting your existing ads to the new expanded format as soon as possible so that you can get your own data about what works best.

And while this script should help most advertisers make the transition quickly, let’s not forget that the real benefit should come when we take the time to craft new messages that take full advantage of the longer ad length.

Source: Expand all your AdWords ads in 30 seconds flat