Join the Webstudio community

Updated 2 months ago

Google Reviews Star rating as a data variable

At a glance
Hi all, I am successfully pulling in Google Reviews into a collection, but I'd like to also bring in the star rating dynamically. It returns as a number, and I tried setting up data-attributes and pass that in, i tried using a conditional for >= 1 star, 2 star, I tried putting it in a collection and passing that in, etc, but nothing seems to work. Any guidance on what I'm missing?
Attachment
image.png
1
J
M
O
13 comments
@Oz are you using the google my business api ?

I would really like to have a solution where I could pull in the general business data dynamically - like address, opening hours anfd so on - also maybe reviews, maybe not .. a lot spammy, annoying marketingstuff in that data.
@Oz I would do something like this :

Put a <div id="star-rating"></div>

And add an HTML Embed with a for loop so it can iterate on your stars depending on the rating.
yes using google business api
thx i will try and report back
Could you write a few lines @Oz about how you did ?

  1. Is it possible just to substitute the ltsting id of the business profile and have it as a template ?
  2. Is it enough just to use my own account and then I can fetch in another account ?
It is a high-value-feature for me to be able to fetch the business data and let the customer change the data on their side of things. This way I just need their approval and they canmanage it on their own.
you just need a working google maps/places API key, and the place ID of any business. I was pulling in businesses i dont control as a test, so you should be able to go to the business profile, and snag the placeID, plus any url params, like
Attachment
image.png
https://maps.googleapis.com/maps/api/place/details/json
?place_id={place_id}
&key={your_api_key}
&fields=reviews,rating,user_ratings_total,name
  1. You can probably set something like this up, where they fill in a form with a place ID and bring it in as a system variable? not sure if you can just have them search by business name though
  2. Yes as long as you're under the monthly limits, or else you're paying for their traffic or billing them
Much appreciated. Really. Thanks for your kind help.
Can you explain with a little more detail? I am struggling to get this working
Attachment
image.png
Can y explain this ??
I managed to do a fetch, it works, but I have a problem, I can't restrict it to webstudio websites, I get the error:
{
"ok": true,
"data": {
"error_message": "API keys with referer restrictions cannot be used with this API.",
"html_attributions": [],
"status": "REQUEST_DENIED"
},
"status": 200,
"statusText": "OK"
}
You probably need to enable google reviews/business api
Add a reply
Sign up and join the conversation on Discord