In short. Tag Manager variables can insert page values into JSON-LD fields and reduce duplicate values in the tag configuration.
Definition: Google Tag Manager can fill a JSON-LD tag with values read from the page through variables. Google's documented example creates a custom variable that returns
document.titleand inserts that result as the Recipe name, so the value is maintained with the page rather than copied separately into the tag.
Key facts
- Google describes Google Tag Manager as a platform for managing website tags without editing the site's code in its JavaScript structured data guide.
- The same guide says variables can use information on the page as part of structured data and reduce the mismatch risk created by duplicating that information in Tag Manager.
- Its example names a custom variable
recipe_name, returns the page title, and then uses{{recipe_name}}in the custom tag HTML. - Google's structured data introduction defines structured data as a standardized format for providing information about and classifying a page.
- The guide's example uses a Recipe object with variables for its name, image, and author name.
How does a page value reach JSON-LD?
A Tag Manager variable is the link between a value already available on the page and a field in the tag. Google's guide shows a custom JavaScript variable named recipe_name whose function returns the document title:
function () {
return document.title;
}
The custom HTML tag then places the variable inside a JSON-LD block. The guide's sample assumes that recipe_name, recipe_image, and recipe_author have been defined in Tag Manager.
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Recipe",
"name": "{{recipe_name}}",
"image": ["{{recipe_image}}"],
"author": {
"@type": "Person",
"name": "{{recipe_author}}"
}
}
</script>
The guide recommends creating variables to collect all the necessary information from the page. This keeps the values in the tag tied to page information instead of requiring a second copy in the Tag Manager configuration.
What should the values describe?
Google's structured data introduction says that markup on a page describes the content of that page. It also says structured data should not describe information that is not visible to the user, even when that information is accurate. A variable therefore needs a page value that corresponds to the property it fills, such as the title used for the Recipe name in Google's example.
The same documentation explains that Google uses structured data found on the web to understand page content. In its JSON-LD example, the recipe title, author, and other details give Google labeled elements to process. Schema.org's Recipe definition describes Recipe as a recipe and defines recipeIngredient as an ingredient or ordered list of ingredients, with quantities represented as free text or more structured values. These definitions give the JSON-LD fields their vocabulary; Tag Manager supplies the page-specific values.
How should the implementation be tested?
Google's JavaScript structured data guide lists a Custom HTML tag, a supported structured data block, container installation, publication, and testing as the implementation sequence. After publishing, its testing instructions recommend entering the URL in the Rich Results Test because the code input has JavaScript limitations, including CORS restrictions. The URL test then runs against the page rather than only the unexpanded template.
If the structured data type is supported by the tool, a successful test displays the message “Page is eligible for rich results.” When a type is not supported, Google says to check the rendered HTML. The same guide says that structured data present in the rendered HTML can be processed by Google Search, while errors or warnings are most likely a syntax error or a missing property.
Related terms
FAQ
Does the Tag Manager value have to match visible page content?
Yes. Google says the structured data on a page describes that page's content and should not add information that is not visible to the user. Use a variable that reads the relevant page value.
Should every field have its own variable?
Google recommends creating variables to collect all the necessary information from the page. Its example defines variables for the recipe name, image, and author before using them in the tag.
Can the Rich Results Test code input run this JavaScript pattern?
Google recommends the URL input instead because the code input has JavaScript limitations, including CORS restrictions. After publishing the container, enter the page URL and test the rendered implementation.
Sources
- Google Search Central, "Generate structured data with JavaScript", 10 December 2025
- Google Search Central, "Introduction to structured data markup in Google Search", 10 December 2025
- Schema.org, "Recipe", undated
Check how a page reads to answer engines. Open the GEO score analyzer