Attribute provided with no value: url at main

276 views
Skip to first unread message

reid hommedahl

unread,
Jan 5, 2023, 5:58:52 PM1/5/23
to Google Ads Scripts Forum
Hi there,

I'm writing a final URL checking script for broken landing pages. It's not letting me log the final URLs and the error I'm getting when I preview it is:
Exception: Attribute provided with no value: URL at main (Final URL Check:15:34)

function main() {

    // log if the function is called
    Logger.log("checkAdLandingPages() function called");
   
    // Get all the active ads in the account
    var adIterator = AdsApp.ads().withCondition("Status = ENABLED").get();

    while (adIterator.hasNext()) {
      var ad = adIterator.next();
      var adURL = ad.urls().getFinalUrl();
      Logger.log(adURL);

      // Use the UrlFetch service to check the HTTP status code of the ad's landing page
      var response = UrlFetchApp.fetch(adURL);
      var statusCode = response.getResponseCode();

      // Logs the url and status code
      Logger.log("Ad URL: " + adURL + ", Status code: " + statusCode);
   
      // If the status code is not 200, send an email notification
      if (statusCode != 200) {
        sendNotification(ad.getId(), adURL);
      }
    }

  // Sends an email notification with the specified subject and body
  function sendNotification(subject, body) {
    // Replace 'YOUR_EMAIL_ADDRESS' with your actual email address
    var recipient = "YOUR_EMAIL_ADDRESS";
    var subject = "Non-404 status code found for ad ID: " + subject;
    MailApp.sendEmail(recipient, subject, body);
  }
}

Can someone please explain to me why the final URLs are null? I have 28 active and approved responsive search ads in the account that all have final URLS. The error seems to be coming from this line:

var adURL = ad.urls().getFinalUrl();

Thank you
Reid

Google Ads Scripts Forum Advisor

unread,
Jan 6, 2023, 1:42:57 AM1/6/23
to adwords...@googlegroups.com

Hi Reid,

 

Thanks for reaching out. Yasmin here from the Google Ads Scripts Team.

 

For us to further investigate your concern, it would be much appreciated if you could provide the following information so we could be able to further investigate this:

  • Google Ads account ID or CID
  • Name of the script
  • Screenshot of the error

 

Kindly send the requested items via `Reply privately to author` option. If the said option is not available on your end, you may send those through the email alias `googleadsscr...@google.com` instead.

 

Best regards,

 

 

Google Logo
Yasmin Gabrielle
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2haGAt:ref
Message has been deleted

reid hommedahl

unread,
Jan 6, 2023, 12:26:45 PM1/6/23
to Google Ads Scripts Forum
Hi Yasmin,

I just sent those details to that email alias and CC'd you.

Thanks, 
Reid

Hommedahl, Reid (PDG-MHW)

unread,
Jan 9, 2023, 4:11:55 PM1/9/23
to Google Ads Scripts Direct Support, adwords...@googlegroups.com

Hi there,

 

Thank you for looking at my script. I added a line to only search for responsive search ads, which solved the issue.

 

Reid

 

From: Google Ads Scripts Direct Support <googleadsscr...@google.com>
Sent: Sunday, January 8, 2023 10:15 PM
To: Hommedahl, Reid (PDG-MHW) <reid.ho...@mediahubww.com>
Cc: adwords...@googlegroups.com
Subject: RE: Attribute provided with no value: url at main

 

Hello, Based on my checking, I can see that your ad with a name of “300x250 Wake up” doesn’t have a final URL, see screenshots attached, which is the main reason why you’re getting the said error upon executing your

Hello,

Based on my checking, I can see that your ad with a name of “300x250 Wake up” doesn’t have a final URL, see screenshots attached, which is the main reason why you’re getting the said error upon executing your script.

Having said that, I strongly recommend double checking the ads in your account and make sure that you have provided its appropriate Final URL in order to avoid no value error message.

Regards,

Image removed by sender. Google Logo

James Howell

Google Ads Scripts Team

 

Image removed by sender.

ref:_00D1U1174p._5004Q2haYSU:ref

This message contains information which may be confidential and privileged. Unless you are the intended recipient (or authorized to receive this message for the intended recipient), you may not use, copy, disseminate or disclose to anyone the message or any information contained in the message. If you have received the message in error, please advise the sender by reply e-mail, and delete the message. Thank you very much.
Reply all
Reply to author
Forward
0 new messages