Everything needs to be done using javascript. It will be injected to the page and the code should be able to extract the product proporties.
Below image is an exmple of a cart page where we have a cart object containing the product data. Similarly I want to know which object is having the product data on PDP page and I need to test that on DevTools → consle similar to the below page -
Is dataLayer something provided by VTEX or by Google Tag Manager. Becuase if it is part of Google Tag Manager, then my organization is not willing put any dependency on 3rd party. What if client decided to remove GTM from their VTEX page?
If dataLayer is part of VTEX product then, I believe I can use that.
I assume you are using VTEX IO, if so…
What product information do you need to display?
I think that @TanishqSharma answer could help you, you need to use that package that has VTEX to be able to make queries with javascript and be able to extract the data of the product of interest in the pdp.
So the plan is to use vannila javascript injection into VTEX and it should be extract the product label details from the product. That is the reason why I was showing the console window of chrome browser. What I can get using the console window, I can put that in my javascipt code.
Yes, this example is with typescript, but you could use it with React as well (which is basically JS).
The other way you have to obtain product information is by querying the VTEX API, for that you need a token. And you would do it with code something like this…