Paying for traffic is expensive.

There is nothing worse than sending traffic to a broken link or page that is down.

Google-Chrome-404-friendly-error-pageYou would think this would be common sense, but at least once a month I click on a ppc ad that goes to a 404 page or a page with some other error code.

It happens to the best of us. We make a change to the website and forget to update the SEM campaign, or perhaps we typed in the wrong URL in the ad, or did some bulk editing and accidentally made a mistake.

When this happens, you are throwing money down the drain, literally!

This is most common with landing pages where you might make changes constantly, or launch new campaigns and take down old ones or simply redesign your site. There are lots of reasons why a landing page might not resolve…but, there is NO EXCUSE to be paying for clicks that you have no chance of converting. 

Hint: It is a good idea to turn your 404 page into a landing page. offers a great 404 template in an easy to deploy format for WordPress sites.

If you are running traffic to dozens or hundreds of pages, it’s hard to know if one goes down.

Here’s a strategy you can follow to monitor your ppc for broken links to make sure your landing pages are always up and running.

There are two versions of this Adwords Script, one which monitors one account and another meant for MCC accounts where you can monitor multiple accounts simultaneously.

As you know, Adwords Scripts programmatically make changes to your Adwords account. While this script works wonders, it only checks your Adwords landing pages. If you happen to be using the same landing pages for Bing and Yahoo,  you’re covered…

I have my script running daily, and it basically checks all the URLs in active campaigns and emails me a report of all the accounts I run. Here is a screenshot of what my reports look like:

If you were to click through to see details, it would show you exactly where the problem links are so you can quickly go in and fix them ASAP.

If you want me to monitor your account for broken links for you, simply email me your Customer ID and once it’s linked in my MCC account, this script will automatically run it for you. You can email me at

If you are more of a DIY kinda guy, here are step by step instructions:

Let’s dive right in. If you need to know how to setup an Adwords script follow the instructions in this post. There are only two small differences. One, you need to upload a different code for the script which will appear below and two, you will need to slightly modify this code to email you the report.

Great, now let’s setup the code to install. There are two options here. Google has a code they created and shared. You can try to implement it, however when I tried it, I got an error message, so I’m not sure how to fix it, but feel free to give it a try…

Good news if it doesn’t work for you though: Russ Savage published a code that works wonders. It installed super quick, and runs like a charm.

* Find Broken Urls In Your Account
* Version 1.1
* ChangeLog v1.1
*  - Updated to only see Text Ads
* Created By: Russ Savage
functionmain() {
  // You can add more if you want:
  varBAD_CODES= [404,500];
  varTO= [''/*,''*/];
  varSUBJECT= 'Broken Url Report - '+ _getDateString();
  //Let's look at ads and keywords for urls
  variters = [
    //For Ad Level Urls
      .withCondition("Status = 'ENABLED'")
      .withCondition("AdGroupStatus = 'ENABLED'")
      .withCondition("CampaignStatus = 'ENABLED'")
      .withCondition("Type = 'TEXT_AD'")
    //For Keyword Level Urls
      .withCondition("Status = 'ENABLED'")
      .withCondition("DestinationUrl != ''")
      .withCondition("AdGroupStatus = 'ENABLED'")
      .withCondition("CampaignStatus = 'ENABLED'")
  varalready_checked = {};
  varbad_entities = [];
  for(varx initers) {
    variter = iters[x];
    while(iter.hasNext()) {
      varentity =;
      if(entity.getDestinationUrl() == null) { continue; }
      varurl = entity.getDestinationUrl();
      if(url.indexOf('{') >= 0) {
        //Let's remove the value track parameters
        url = url.replace(/\{[0-9a-zA-Z]+\}/g,'');
      if(already_checked[url]) { continue; }
        Logger.log("Testing url: "+url);
        response_code = UrlFetchApp.fetch(url, HTTP_OPTIONS).getResponseCode();
      } catch(e) {
        //Something is wrong here, we should know about it.
        bad_entities.push({e : entity, code : -1});
      if(BAD_CODES.indexOf(response_code) >= 0) {
        //This entity has an issue.  Save it for later.
        bad_entities.push({e : entity, code : response_code});
      already_checked[url] = true;
  varcolumn_names = ['Type','CampaignName','AdGroupName','Id','Headline/KeywordText','ResponseCode','DestUrl'];
  varattachment = column_names.join(",")+"\n";
  for(vari inbad_entities) {
    attachment += _formatResults(bad_entities[i],",");
  if(bad_entities.length > 0) {
    varoptions = { attachments: [Utilities.newBlob(attachment, 'text/csv', 'bad_urls_'+_getDateString()+'.csv')] };
    varemail_body = "There are "+ bad_entities.length + " urls that are broken. See attachment for details.";
    for(vari inTO) {
      MailApp.sendEmail(TO[i], SUBJECT, email_body, options);
//Formats a row of results separated by SEP
function_formatResults(entity,SEP) {
  vare = entity.e;
  if(typeof(e['getHeadline']) != "undefined") {
    //this is an ad entity
  } else{
    // and this is a keyword
//Helper function to format todays date
function_getDateString() {
  returnUtilities.formatDate((newDate()), AdWordsApp.currentAccount().getTimeZone(), "yyyy-MM-dd");
Simply copy and paste that code into the scripting section in Adwords, authorize the script, set the scheduling to run daily, and you are all set to go.
Just make sure you change the email address in this script '' to your actual email address and/or anyone else you want to email.
If you are running an MCC account, the setup process is slightly different and you may need to setup a copy of a google spreadsheet. Here are Russ Savage’s instructions for MCC accounts.

By Jeremy Schoemaker

Jeremy "ShoeMoney" Schoemaker is the founder & CEO of ShoeMoney Media Group, and to date has sold 6 companies and done over 10 million in affiliate revenue. In 2013 Jeremy released his #1 International Best selling Autobiography titled "Nothing's Changed But My Change" - The ShoeMoney Story. You can read more about Jeremy on his wikipedia page here.

25 thoughts on “Ensure You Never Send Paid Traffic To a 404 Page or Broken Link”
    1. You are very welcome. Look out for my next post about tracking 404’s in Analytics.

      1. Speaking of 404 pages; if your 404 page is able to put a smile on the visitos face then things might not be so bad. A smiling visitor is (more) likely to stick around.

        You could show a ‘recommendation’ on that same 404 page leading the visitor to either another page on your website or to an affiliate link somewhere.

        Of course the visitors wouldn’t be targeted so it is just for the exceptions. Monitoring the 404 page visits is still required so you know which links out there have to be fixed or rerouted to the proper page.

  1. I’ve always wanted to be able to prevent this from happening. I just didn’t know there was a way.

    1. There’s actually a bunch of ways. For example, PPCHero has a script in their pro account that automatically pauses your ads if its going to a 404 page.

  2. This seems very useful but I’m still very much intimidated by the thought of doing this.

      1. I would be happy to set this up for you if you want. It takes 2 minutes. Just email me at david (at)

  3. This was a good read, I like your posts and tips very much. Please keep writing good materials so I can keep learning more each day.

    1. My pleasure. I would encourage you to check my blog at regularly as I share my best stuff there. (dig through the archives for some real gems.)

  4. There is nothing more irritating that wanting to read or buy something and then when you click the link it’s broken. I mean talk about lost money! I think every company out there with a website needs to read this piece and fix their site so it doesn’t happen to them.

    1. Next time this happens to you, be sure to forward this post to them. They’ll appreciate it.

  5. I LOVE this blog. David, you and Jeremy have taught me so much over the last couple months. I check this blog every day to see what I can do better as I jump into starting my own blog and affiliate marketing.

    1. I can only take credit for 21 posts so far, but I’m glad you are learning from them. Make sure to read TaeWoo’s stuff as well, it is dead on.

  6. You’re dead on. Traffic is so expensive why waste money on it if you’re just going to send it to a non-functioning page. Just piss away the money!

    1. I know. It constantly blows my mind seeing how much money is being wasted all around me. Unfortunately though, if people stopped wasting money, the economy might just collapse 🙂 j/k

  7. Hi, David! 🙂

    I think anyone who will read this article of yours would agree with you, and would not ask for further explanation.

    As what you’ve said, paid traffic is expensive. So, it is just right that you ensure you didn’t send paid traffic to broken links. It’s a common sense, just like what you’ve also thought.

    If this thing will happen, whether an accident or not, you’re just throwing money. You must be practical and wise nowadays. You work hard to earn money online, and not to throw away money online.

    Thanks for sharing what you know! You’re such a help, especially for marketers.

    Good day! 🙂


    By the way, I found this post shared on

  8. David, you are fast becoming the worlds leading expert on adwords tips! Another home run, keep up the great work.

  9. Well, I never thought of it until now. This is indeed a serious issue. For me, I were in this scenario, I will choose your first advice and turn the 404 page into a landing page, so there is no worries. The second option is little complicated and I will prefer to stay out of it. There might be some tracking problems though. I loved the article, it will help many like me who were not even aware of this issue.

    Anyway, I found the link to this article on kingged.

  10. Thank you for sharing this wonderful strategy.

    Details for Adwords Scripts version are very helpful

  11. Hi, everything is going well here and ofcourse every one is sharing information, that’s really fine, keep up writing. dcdegebacdke

Comments are closed.