How to add script tag or source code in hybris WCMS component ?

Requirement :
To enable google structure data for Organization and WebSite search I want to add the script (application/ld+json) on Hybris homepage using WCMS component.

Problem: I have chosen the paragraph component and added it to the one of available WCMS slot. But not able to add a script in the editor, as XSS filter remove script while saving to DB.

Workaround: Disable XSS filter for while using xss.filter.enable= false (from hac), save the script (editor > select source > past your script) and then agian enable the xss filter.



Structure data application/ld+json:

<script type='application/ld+json'> 
{
  "@context": "http://www.schema.org",
  "@type": "Organization",
  "name": "MyCompnay USA, Inc.",
  "url": "https://www.MyCompnayusa.com/",
    "logo": "http://www.MyCompnayusa.com/web/media/system/layout/images/logo.gif",
  "description": "Established in 1990, MyCompnay USA is one of the leading suppliers",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "93 Grant Street",
    "addressLocality": "Ramsey",
    "addressRegion": "NJ",
    "postalCode": "07446",
    "addressCountry": "US"
  },
  "contactPoint": {
    "@type": "ContactPoint",
    "telephone": "+1-800-987-8487",
    "contactType": "Customer Service"
  },
  "sameAs" : [ 
    "https://www.facebook.com/MyCompnayusa",
    "https://twitter.com/MyCompnay_usa",
    "https://www.linkedin.com/company/MyCompnay-usa",
    "https://www.youtube.com/user/MyCompnayUSAInc"]
}
</script>

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://www.MyCompnayusa.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://www.MyCompnayusa.com/search/?text={search_term_string}",
    "query-input": "required name=search_term_string"
  }
}
</script>

Author Image

Ankitkumar Patel

Sr. SAP Hybris consultant, having 15+ years experience in SAP Commerce Cloud (Hybris), SAP Spartacus. Extensive experience in SAP Hybris development, third-party integrations, project architecture and design... Read more

Comments

Popular posts from this blog

Hybris flexible search query examples

How to Install temporary Hybris license?

How to remove or update all data records in Hybris?