Migrating to new Google Ads Scripts experience

Migrating to new Google Ads Scripts experience

If you have only 2 minutes:

  • Google Adwords API will no longer be supported
  • Users need to update their scripts until 31st of OCT to switch to Ads API
  • Google says the new version should be backwards compatible
  • In some cases, errors arise and scripts return wrong values
  • Check-out some useful scripts to use

Introduction

This year, Google announced that Google Adwords API will no longer be supported and users need to update their scripts until 31st of October in order to switch to the new script engine and therefore to the Ads API.

In order to run a script with the new Ads Scripts engine, Google is now offering a checkbox above every script that users need to check so that the script can run in the new platform.

The new Google Ads Scripts

At a first glance, something very easy to do if you want to keep your script just as it is and let Google take care of the translation of your code in the new platform. Because yes, Google says that the new version should be backwards compatible in most cases.

But, during this process, while we encountered several situations where scripts were running fine there were also cases where errors started to arise or scripts were retrieving wrong values.

Below we will give some details about the things that we’ve encountered during the migration of our scripts.

Query translation

With the new API, there is a new data structure that you need to query in order to retrieve all Campaigns, AdGroups, Ads details.
You have now other tables, other columns and also different ways of accessing some data.

For example a query in AdWords that looked like this:

SELECT CampaignId, CampaignName FROM CAMPAIGN_PERFORMANCE_REPORT WHERE CampaignStatus IN [‘ENABLED’] DURING TODAY

Now looks like this:

SELECT campaign.id, campaign.name FROM campaign WHERE campaign.status IN (‘ENABLED’) AND segments.date DURING TODAY

The data is now structured in more tables and you need to modify the queries in order to retrieve the same data as before.

Google migration tool

Google is currently offering a tool for migrating the queries. You just need to write your old query, press convert and it will retrieve the new query.

We attached below a screenshot using the same query as above:

Google Ads Scripts Migration Tool

The tool does not guarantee that the query is 100% ok converted. Also, the tool is online and can be found at https://developers.google.com/google-ads/api/docs/migration/query-migration-tool

Deprecated fields

One thing that you should take into consideration for your queries is that more than 100 fields from the old AdsWords API were deprecated.

You can find within the documentation a mapping of all fields, for every entity.
The migration documentation has a page dedicated to this.
https://developers.google.com/google-ads/api/docs/migration/mapping
You should be aware that when a query containing deprecated fields is translated, those fields will not appear anymore within the new query. Nevertheless, this is shown as a warning below the translated query.

As an example from the migration tool:

Deprecated fields in the new Google Ads Scripts

Try to identify all deprecated fields within your queries so that you can remove them from your script logic.

Automatic query translation

For those queries that you do not change but you still want to run in the New Experience Script platform, Google does an automatic translation of them where it tries to run them.

So far so good, you will not have to change anything in your code and it will run.
But there are things that we’ve encountered during our migration using this feature:

  1. Performance loss – your script will take longer to execute due to this translation behind the scenes. If you know you have a script that has many queries and takes several minutes, you might need to change the queries to the new API because you might face the timeout after 30 minutes of script run.
  2. Fields values misleading – there are situations in which the translation returns bad results due to the structure changes in several tables and entities. For example:

SELECT CampaignId, CampaignName, Labels FROM CAMPAIGN_PERFORMANCE_REPORT

This query returns, in the old language, for the “Labels” field, an array containing the names of all labels in the campaign.
If “New Script Experience” is checked, the query will return an array containing the IDs of the labels, instead of the names, so the result will differ & will affect the business logic of your script.

Performance Max campaigns

When switching to the new Script Experience, we are now able to see the results of our Performance Max campaigns in the campaign queries. These campaigns were not shown until now.

Possible errors in scripts

  1. During the scripts migration we encountered an error appearing for multiple scripts and we couldn’t find a fix by changing part of the code.

If you face the error below:
ReferenceError: AdsApp is not defined (line 1)

We managed to solve it by simply copying the script content into another new Script and enabling the New script experience checkbox. This error appeared when we took an old script, checked the “New experience” checkbox and simply tried to run it again. Apparently there is a bug within the Google Ads Script platform that throws this error when you simply try to re-run a script. After several investigations and web browsing, the only way we’ve managed to solve it was by simply copying the script content into a newly created script. After this, the new script ran just fine without other changes. The script was also configured with the “New experience” check-box checked.

2. We’ve encountered fields that are internally marked as Datetime fields but are shown in the api as DATE fields. For example, in the “call_view” entity we have the field “call_view.start_call_date_time”.

Types of errors in the new Google Ads Scripts

You should pay attention when using this kind of fields (date_time fields) within the queries for filtering as they take into consideration the time as well, beside the effective date.

For example:
SELECT call_view.start_call_date_time FROM call_view WHERE call_view.start_call_date_time BETWEEN “2022-10-18 00:00:00” AND “2022-10-18 23:59:59” Will retrieve all the results for that specific day, which is not the case if you use the query as the one below: SELECT call_view.start_call_date_time FROM call_view WHERE call_view.start_call_date_time BETWEEN “2022-10-18” AND “2022-10-18”

Other (very) useful scripts you should be aware of

”0” impression pause

Ideally, ads respond to the right keywords, spark curiosity, make users interact with the brand and eventually make a purchase. From time to time though, there are certain ads that don’t perform – either because there is a technical issue or an error in set-up. To avoid those ads generating waste, use this script and stop them from being active in the campaign.

Broken URLs report

Broken URLs sneak-up on us, and they are not pretty to have. Thankfully, there is a script that helps us be aware of URLs that return 404 Not Found or 500 Server Error response codes, and avoid them.

Link checker script

No more 404s. If there are ads in your account that are returning a broken link, this script will let you know. More so, you can choose when the script will be performing the checking.

Ad spend report script

Real-time check of how the campaign is performing is extremely important, especially in cases like Black Friday or other intense moments. The Ad spend report script will update you on your email on specific metrics, revolving around budget spent:

  • ad spend
  • conversions
  • CPA
  • recommended daily spend
  • current daily spend