Introduction
In today’s digital age, online reviews play a crucial role in the decision-making process of consumers. For businesses, these reviews are valuable as they provide an authentic and transparent snapshot of their service quality.
Why Integrate Google Reviews on Your Site?
Positive reviews enhance credibility and authenticity of your business in the eyes of site visitors. Additionally, customer reviews can boost your search engine rankings.
How to Integrate Google Reviews on Your WordPress Site
Before you start, ensure you have billing enabled in your Google Cloud account as the Google Places API is a paid service beyond a certain quota. Enable billing here.
Here’s how to proceed with integrating Google Reviews on your WordPress site:
Step 1: Retrieve Your Google Places API Key
- Go to your Google API Console and log in.
- Select or create a project.
- Click on “APIs & Services” then “ENABLE APIS AND SERVICES”.
- Search for “Places API” and enable it.
- Copy your newly created API key. Restrict it to your domain for security.
Step 2: Find Your Google Place ID
- Use Google’s Place ID search tool.
- Search for your business and copy the “Place ID”.
Step 3: Create a PHP Snippet
- Insert the following code into the
functions.php
file of your WordPress child theme:
function trz_fetch_google_reviews($atts) {
$api_key = "YOUR_API_KEY_HERE";
$place_id = "YOUR_PLACE_ID_HERE";
$url = "https://maps.googleapis.com/maps/api/place/details/json?placeid=$place_id&key=$api_key&language=en";
$response = wp_remote_get($url);
if( is_wp_error( $response ) ) {
return;
}
$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);
$reviews_html = '';
if( isset($data['result']['reviews']) ) {
foreach( $data['result']['reviews'] as $review ) {
$reviews_html .= '<div class="google-review">';
$reviews_html .= '<p><strong>' . $review['author_name'] . '</strong></p>';
$reviews_html .= '<p>' . $review['text'] . '</p>';
$reviews_html .= '<p><em>Rated: ' . $review['rating'] . ' stars</em></p>';
$reviews_html .= '</div>';
}
}
return $reviews_html;
}
add_shortcode('trz_google_reviews', 'trz_fetch_google_reviews');
Step 4: Use the Shortcode on Your Site
- You can now use the shortcode
[trz_google_reviews]
in your posts, pages, or widgets to display Google Reviews on your site.
Conclusion
Integrating Google Reviews on your WordPress site not only adds a layer of authenticity and trust but also engages potential customers by showcasing real, positive experiences from other clients. This creates a bridge of trust and credibility, promoting a solid reputation online.
If you have any questions or need additional assistance integrating your Google reviews on your website, feel free to contact us.