Add code and structured data

Add code to a page's head or body, and add or replace structured data (JSON-LD).

You can add your own code to a page's head or body, and add or replace the structured data (JSON-LD) that search engines read. You don't need to edit your site's code.

 

When to use it

  • You want to add an analytics tool or ad tag only to certain pages
  • You want to add structured data such as products, FAQs, or company info so your pages look richer in search results
  • The structured data your shop platform adds is wrong and you want to replace it

 

Code injection (custom code)

  1. Open the Code injection (custom code) field in the rule and click + Add code.
  2. Choose the Position and paste the code.
Position Where it goes
Start of head Right after <head>
End of head Right before </head>
Start of body Right after <body>
End of body Right before </body>

Example: to add an ad conversion tag only to event pages, add the tag to the path /event/* at End of head.

 

Structured data (JSON-LD)

  1. Open the Structured data (JSON-LD) field in the rule and click + Add structured data.
  2. Paste one JSON-LD object at a time.
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "Example Inc.",
  "url": "https://www.example.com",
  "logo": "https://www.example.com/logo.png"
}

If the original page already has structured data with the same @type, it's replaced with what you added. If not, it's added.

 

Good to know

  • Each structured data item needs an @type, and a rule can't have the same @type twice.
  • If it isn't a valid JSON object, you'll be told when you save.
  • You can check the structured data with the Google Rich Results Test.
  • Injected code runs as is on visitors' screens. Please add only code you trust.
  • Code injection and structured data don't apply to rules that use a redirect or response code.