Jump to content

Help Please!! SEMRush Gives Me This Error -- A value for the name field is required.

Go to solution Solved by AnnaRadzicki,

Recommended Posts

I have asked SquareSpace and they were very unhelpful. Here's my issue:

My site is live, but the SEMRush Audit is showing 19 errors --- all of them are "A value for the name field is required." When I look further, it says "Name" and "Address" are affected. 

I did some research, and it seems like the fix here is to use some code to update the site. I have the code, and it seems correct with no errors. However, when I try to add the code to my footer with the Code-Injection feature, it never shows up. 

Can someone help? What am I doing wrong, and how can I fix it? 

 

This is the code:
 

<script>
  document.addEventListener("DOMContentLoaded", function() {
    var elements = document.querySelectorAll('script[type="application/ld+json"]');
    elements.forEach(function(element) {
      try {
        var jsonData = JSON.parse(element.innerHTML);

        // Update LocalBusiness schema
        if (jsonData['@type'] === 'LocalBusiness') {
          if (!jsonData.name || jsonData.name === "") {
            jsonData.name = “Clever Creative Content”;
          }
          if (!jsonData.url || jsonData.url === "") {
            jsonData.url = "https://www.clevercreativecontent.com";
          }
          if (!jsonData.logo || jsonData.logo === "") {
            jsonData.logo = "URL of your logo";
          }
          if (!jsonData.address || jsonData.address === "") {
            jsonData.address = {
              "@type": "PostalAddress",
              "addressLocality": “Berea”,
              "addressRegion": “OH”,
              "postalCode": “44017”,
              "streetAddress": “347 Fair St “,
              "addressCountry": “US”
            };
          }
          if (!jsonData.telephone || jsonData.telephone === "") {
            jsonData.telephone = “(216) 600-8091”;
          }
          if (!jsonData.priceRange || jsonData.priceRange === "") {
            jsonData.priceRange = “$”;
          }
          if (!jsonData.currenciesAccepted || jsonData.currenciesAccepted === "") {
            jsonData.currenciesAccepted = “US”D;
          }
          if (!jsonData.paymentAccepted || jsonData.paymentAccepted === "") {
            jsonData.paymentAccepted = "Credit Card”, “PayPal”;
          }
          if (!jsonData.openingHoursSpecification || jsonData.openingHoursSpecification.length === 0) {
            jsonData.openingHoursSpecification = [
              {
                "@type": "OpeningHoursSpecification",
                "dayOfWeek": [
                  "Monday",
                  "Tuesday",
                  "Wednesday",
                  "Thursday",
                  "Friday"
                ],
                "opens": "09:00",
                "closes": "17:00"
              },
              {
                "@type": "OpeningHoursSpecification",
                "dayOfWeek": [
                  "Saturday"
                ],
                "opens": "10:00",
                "closes": "14:00"
              }
            ];
          }
          element.innerHTML = JSON.stringify(jsonData);
        }

        // Update Organization schema
        if (jsonData['@type'] === 'Organization') {
          if (!jsonData.legalName || jsonData.legalName === "") {
            jsonData.legalName = “Clever “Creative Content”;
          }
          element.innerHTML = JSON.stringify(jsonData);
        }

      } catch (e) {
        console.error("Error parsing JSON-LD: ", e);
      }
    });
  });
</script>

Screenshot 2024-08-14 at 3.15.48 PM.png

Screenshot 2024-08-14 at 3.15.08 PM.png

Link to comment
  • Replies 3
  • Views 1.4k
  • Created
  • Last Reply

Top Posters In This Topic

  • 4 weeks later...
  • Solution
On 8/19/2024 at 10:33 AM, Christa1024 said:

I really need help with this if anyone is out there. 

Okay so after HOURS of searching for an answer, I found a solution!!! 

Fill this code out with your business information, it currently has the company information for Kalglo, so adjust your information as needed. Business name, address, hours, etc. 

<script>
  document.addEventListener("DOMContentLoaded", function() {
    var elements = document.querySelectorAll('script[type="application/ld+json"]');
    elements.forEach(function(element) {
      try {
        var jsonData = JSON.parse(element.innerHTML);

        // Update LocalBusiness schema
        if (jsonData['@type'] === 'LocalBusiness') {
          if (!jsonData.name || jsonData.name === "") {
            jsonData.name = "Kalglo";
          }
          if (!jsonData.url || jsonData.url === "") {
            jsonData.url = "https://www.kalglo.com";
          }
          if (!jsonData.logo || jsonData.logo === "") {
            jsonData.logo = "https://images.squarespace-cdn.com/content/v1/660c4e785b13d204bb3dfc63/f5f5b942-da83-4772-b834-ea447cefeb4c/kalglo+logog.gif?format=1500w";
          }
          if (!jsonData.address || jsonData.address === "") {
            jsonData.address = {
              "@type": "PostalAddress",
              "addressLocality": "Fogelsville",
              "addressRegion": "PA",
              "postalCode": "18051",
              "streetAddress": "2010 Sunset Drive",
              "addressCountry": "US"
            };
          }
          if (!jsonData.telephone || jsonData.telephone === "") {
            jsonData.telephone = "(610) 837-0700";
          }
          if (!jsonData.priceRange || jsonData.priceRange === "") {
            jsonData.priceRange = "$$";
          }
          if (!jsonData.currenciesAccepted || jsonData.currenciesAccepted === "") {
            jsonData.currenciesAccepted = "USD";
          }
          if (!jsonData.paymentAccepted || jsonData.paymentAccepted === "") {
            jsonData.paymentAccepted = "Credit Card, PayPal, Klarna";
          }
          if (!jsonData.openingHoursSpecification || jsonData.openingHoursSpecification.length === 0) {
            jsonData.openingHoursSpecification = [
              {
                "@type": "OpeningHoursSpecification",
                "dayOfWeek": [
                  "Monday",
                  "Tuesday",
                  "Wednesday",
                  "Thursday",
                  "Friday"
                ],
                "opens": "08:00",
                "closes": "17:00"
              }
            ];
          }
          element.innerHTML = JSON.stringify(jsonData);
        }

        // Update Organization schema
        if (jsonData['@type'] === 'Organization') {
          if (!jsonData.legalName || jsonData.legalName === "") {
            jsonData.legalName = "Kalglo";
          }
          element.innerHTML = JSON.stringify(jsonData);
        }

      } catch (e) {
        console.error("Error parsing JSON-LD: ", e);
      }
    });
  });
</script>

Copy the updated code and check the validity with https://search.google.com/test/rich-results. If all looks good copy and past the code into Code Injections, Footer. You can test your website with https://search.google.com/test/rich-results to make sure everything is working properly. I hope this helps! 

Link to comment
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.