Skip to content

Change URLs for multiple AdWords ads with script

Let’s say you have 400 ads running in Google AdWords with final URLs that leads to your landing pages and your developers decide to change the entire URL structure. Now you have to change ALL your ads to point to the new URLs instead. No matter if you need to change 10 ads or 5 000 ads, the following function will come in handy.

Step 1

The first thing you will have to do is create a new Google sheet and add two columns; one for the old URLs and one with the new URLs. The columns should match each other in a way that each row contains the matching new URL as below.

 

Step 2

In order for the script to work, you will have to create an array containing all URLs as elements. The easiest way to do this is to copy the list of your URLs and paste them into the second box on the following site: http://mergewords.com/. In the first box you will enter a quotation mark and in the third box a another quotation mark followed by a comma (see picture below).

Copy the generated list and paste it into Excel or another tool where you can merge multiple rows into a single line (my favourite is Notepad++ where you can simply choose to remove line breaks). What you want is a single line that looks like the following:

“url-example1”, “url-example2”, “url-example3”

Repeat this procedure for the corresponding URLs in the second column from step 1 so that you have two lines with elements where the new URL is placed in the same position as its corresponding old URL.

 

Step 3

Write the script in AdWords. Copy the following script and replace the parts that are highlighted with the strings you just created.

The script will go through all ads matching the conditions chosen in the beginning. If an ad’s final URL matches one of those listed in the array of old URLs a functon will run which creates a new ad with the exact same information as the current one but with the new URL listed in the array of new URLs. The current ad will be labled “old_urls” and the new one will be labled “new_urls”. Also, the new ad will automatically be paused.

Notice that the script removes the ending slash (if there is one) which means that the list of original URLs have to be written without the ending slash. The reason for this is to make sure that there aren’t URLs written with ending slash in some ads and without ending slash in other ads. With this function the script will find all occurances no matter what.

 

Step 4

When the time comes for the redirects to be made you can easily filter all ads labled “old_urls” and remove them. Then you can filter out all ads labled “new_urls” and activate them. Or even better, you can create a rule that will automatically pause the old ads and activate the new ones at a certain time if you know when the redirects will implemented.

Share this article
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Published inAdWords

Leave a Reply

Be the First to Comment!

Notify of
avatar
© Copyright 2017-2018 - Linus Larsson