How to read values from a view to insert in ratingValue and ratingCount in my web in order to be recognized by Google Structured data testing tool?
36 views
Skip to first unread message
Javier López-Escobar
unread,
Jun 10, 2022, 2:21:44 PM6/10/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Forum Blogger Ambassade Francophone
I was using an external service to get Aggregate Rating in my recipes blog, but dis service disappeared so I decided to build one myself. First of all, this is my first experience with cloud data and JavaScript programming so please, be paciente with me :-).
I'm doing my experiments in this duplicate of my blog: https://jleavalc.blogspot.com/ by now it works as I planned, letting one to vote and storing results in a oracle table, making it possible to retrieve results from a view of this table to get ratingCount and ratingValue values, as anyone can see in that link... But at the end, despite you can see the stars, despite you can vote and get result stored, showing voting results, Structured data testing tool don't see tag values, so all work is useless.
I think I'm getting close to the problem, but not getting close to the solution. I have the impression that the cause of my problems is the asynchrony of the execution of the script that brings the data from the table, while the function is executed, the browser continues to render the page and it doesn't arrive in time to write those values before the google tool can read them, so they appear empty to it. I have tried everything including labels and variables in GTM with the same result. The latest version of the code, from this morning is installed right before the "/head" tag and it looks like this:
// This version gives the same result and is interchangeable with the previous one. I keep it commented so as not to forget it: // var settings = { // "url": "https://ge4e65cc87f573d-db20220526112405.adb.eu-amsterdam-1.oraclecloudapps.com/ords/admin/notas/?q={\"receta\":{\"$eq\":\"" + myPostId + "\"}}", // "method": "GET", // "timeout": 0, // "async": false, // }; // $.ajax(settings).done(function (response) { // if (response.items.length != 0) { // micuenta = response.items[0].votos; // nota = response.items[0].media; // } // }); </script>
The key is, I think, getting this call to execute before Google's tool finishes rendering the Blogger post page. The URL that I invoke to get the data calls an oracle view that returns a single row with the corresponding data from the recipe, placing this call: [recipe][1]
And I just need to take the median and votes values to create the RatingCount and RatingValue labels Can anyone offer me an idea that solves this little problem? :-)