When live testing a URL on Google Search Console, Googlebot can render a page but my structured data is missing. It is generated in JS via:
insertStructuredData(genDataFn: Function): void {
this.removeStructuredDataElement();
let script = this.getStructuredDataElement();
if (!script) {
script = document.createElement('script');
script.type = 'application/ld+json';
script.id = STRUCTURED_DATA_TAG_ID;
document.head.appendChild(script);
}
safeScriptEl.setTextContent(script, scriptFromJson(genDataFn()));
}
When I view the page myself it shows up just fine:
<script type="application/ld+json" id="structuredDataScriptTagId" nonce="abcdefg">...</script>
But when I view the HTML that Googlebot see on the Live test, this tag is missing from the page. Is this purely a latency issue or could there be anything else impacting this tag's visibility to Googlebot?
There are a few things that you can check:
That's basically al you can do, but even then, Google will decide whether to use or not the data defined on your structured-data objects; as they have stated on the official documentation The actual appearance in search results might be different