Google Structure data using JSON LD and Google Tag manager

OS info

Problem description

I am trying to implement Json Ld using google tag manager, and script for json ld is generated by gtm dynamically when my product detail page is hit in url in my ecommerce website. GTM tries to read product information from div id which i mentioned in gtm variables.
But because my product detail page is made inside the route. gtm is getting value of div id, but if i place same div id on index page or outside the route it works but not on route pages.

Community Page
Last updated: