I use GTM queryselector variables to populate the JSON-LD structured data on my pages dynamically - or at least I'm trying to. The variables are pulled correctly in GTM preview mode, they render fine in Chrome Console, but they load as 'undefined' in Google Rich Results test! Here's an example:

![variable Custom JS Variable

custom html Structured Data JavaScript in GTM (custom HTML tag)

render Render readout in Chrome Console

rich results Rich Results: undefined

The site (https://thechartcast.com) is on WordPress and I'm wondering if some plugin could be messing with the Googlebot render, or something.

  • I'd also point out that the built-in variables for GTM, e.g. Page URL, are rendered perfectly fine in the Rich Results test, which leads me to believe that maybe something is afoot with the dynamic rendering of the DOM.
    – I Capulet
    Commented Nov 30, 2020 at 17:21

1 Answer 1


I got it to work yay! I installed a prerenderer WP plugin specifically for Googlebot (prerender.io) and switched around some of the variable selectors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.