– Document queryselector-based variables in structured data via GTM keep returning ‘undefined’ in Rich Results Test

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:

Custom JS Variable

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

Render readout in Console

rich results
Rich Results: undefined

The site ( is on WordPress and I’m wondering if some plugin could be messing with the Googlebot render, or something.