AdWords
2.2K members online now
2.2K members online now
For questions related to Google Shopping and Merchant Center. Learn to optimize your Shopping ads
Guide Me
star_border
Reply

Structured Product Data Not Working With JavaScript

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I am attempting to add product microdata for Automatic Item Updates, but my price value is naturally in the wrong format and I do not have access to the back end for insertion of a correct format via PHP. I added JavaScript that appends the correct microdata into the offers structured data section, but merchant center is not recognizing that the new price field even exists. Is there something I am missing or is there a better way to modify the price format for Google without access to the back end?

Below is the code that is not working properly.

<span id="priceData" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<meta itemprop="priceCurrency" content="USD"/>
<link id='itemAvailability' itemprop='availability' href='http://schema.org/InStock'/>
<link itemprop="itemCondition" href="http://schema.org/NewCondition"/>
</span>


<script>
var currency = document.getElementById("itemPrice").innerHTML;
var numValue = Number(currency.replace(/[^0-9\.]+/g,""));
document.getElementById("priceData").innerHTML = document.getElementById("priceData").innerHTML + " <meta id='itemPriceGoogle' itemprop='price' content= " + numValue + ">";
</script>

I should mention that Google Webmaster Tools Structured Data Report shows the correctly formatted price data so the Google crawler can see it. Why can't Google Merchant Center?

Any help would be appreciated.

Thank you

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by MosheTLV (Top Contributor)
July

Structured Product Data Not Working With JavaScript

[ Edited ]
Top Contributor
# 2
Top Contributor

unfortunately, currently, structured-data-markup for shopping-ads

cannot be generated using server-side-scripting or after the page

has loaded -- such as with javascript.

all structured-data values must be implemented using either

server-side-scripting, such as php, python, etc., or hard-coded.

also, pages cannot adapt values based on any user-specific details --
for example, a different currency based on ip-address or user-agent.

the structured-data format for shopping-ads must
be either (a) json-ld or (b) micro-data, but not both,

on a landing-page.

structured-data-markup is optional -- however, if implemented with shopping-ads
then, structured-data details must adhere to all the rules and polices related
to shopping-ads; the rules and requirements for shopping-ads (structured-data)

are simply different from organic-google-search.

 

see also
https://support.google.com/merchants/topic/6386199

 

View solution in original post

Marked as Best Answer.
Solution
Accepted by MosheTLV (Top Contributor)
July

Structured Product Data Not Working With JavaScript

[ Edited ]
Top Contributor
# 2
Top Contributor

unfortunately, currently, structured-data-markup for shopping-ads

cannot be generated using server-side-scripting or after the page

has loaded -- such as with javascript.

all structured-data values must be implemented using either

server-side-scripting, such as php, python, etc., or hard-coded.

also, pages cannot adapt values based on any user-specific details --
for example, a different currency based on ip-address or user-agent.

the structured-data format for shopping-ads must
be either (a) json-ld or (b) micro-data, but not both,

on a landing-page.

structured-data-markup is optional -- however, if implemented with shopping-ads
then, structured-data details must adhere to all the rules and polices related
to shopping-ads; the rules and requirements for shopping-ads (structured-data)

are simply different from organic-google-search.

 

see also
https://support.google.com/merchants/topic/6386199