> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.alireviews.io/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# [Integrations] How to Manually Add Google Rich Snippets to a Custom Theme

## What this does

Ali Reviews adds Google Rich Snippets (star ratings and review data) to your products automatically once they have reviews. However, on some themes — especially heavily customized or third-party themes — the rating data can't be injected automatically, so the stars won't appear in Google search results.

This guide shows you how to add the rich snippet data to your theme by hand. It's a technical task that involves editing your theme code, so it's best suited to store owners comfortable with Shopify's code editor, or your developer.

> **Prefer not to touch code?** Contact us via live chat or at [support@alireviews.io](mailto:support@alireviews.io) and our team can help you apply this for you.

## Before you start

* Confirm the automatic method didn't work first. See [Does Ali Reviews integrate with Google Rich Snippets?](https://help.alireviews.io/en/article/does-ali-reviews-integrate-with-google-rich-snippets-1vwolkb/) — try the **Rich Snippets → Update** button in **Manage reviews** before editing any code.
* Google Rich Snippets is available on the **Basic** plan and higher.
* You'll need access to **edit your theme code** (Online Store → Themes → Edit code).
* **Duplicate your theme before editing** so you can roll back if anything goes wrong (Online Store → Themes → ⋮ → Duplicate).
* Make sure the product you're testing actually has reviews and that Ali Reviews has generated its rating metafield (this happens automatically after a product receives reviews).

## Step 1: Check whether rich snippet data is already present

Before editing anything, confirm the data really is missing:
1. Open one of your product pages in your browser.
2. Right-click the page and choose **View page source**.
3. Use **Ctrl/Cmd + F** to search the source for ld+json or aggregateRating.
4. You can also run the page through Google's [Rich Results Test](https://search.google.com/test/rich-results).

If you don't find aggregateRating in the source and the Rich Results Test shows no review/rating data, continue to the next step. Most recent cases like this come down to structured data (JSON-LD) that your theme builds itself, without the Ali Reviews rating merged in.

![](https://storage.crisp.chat/users/helpdesk/website/-/5/1/8/4/51849c8de000cc00/image_1nb82hf.png)
## Step 2: Find your theme's structured data file

1. Go to **Online Store → Themes**.
2. On your live (or duplicated) theme, click **⋮ → Edit code**.
3. Use the code editor's search to look for the keyword ld+json. You're looking for a line similar to:

```liquid
<script type="application/ld+json">{{ product | structured_data }}</script>
```

This snippet usually lives in a theme file such as:
* snippets/microdata-schema.liquid — in the **Prestige** theme
* snippets/structured-data.liquid — in the **Kalles** theme

Your theme may use a different file name, but the ld+json search will point you to the right one.

![](https://storage.crisp.chat/users/helpdesk/website/-/5/1/8/4/51849c8de000cc00/image_dkjqqq.png)
## Step 3: Merge the Ali Reviews rating into the structured data

Replace the existing ld+json script block with the code below. This checks for the Ali Reviews rating metafield (product.metafields.alireviews.seo_rating_review_key_script) and, if it has a value, inserts the rating data into your theme's existing structured data:
```liquid
{% assign product_structured_data = product | structured_data %}
{% assign rating_data = product.metafields.alireviews.seo_rating_review_key_script | remove_last: ',' | strip %}
{% if rating_data != blank %}
{% assign last_brace_index = product_structured_data | split: '' | reverse | join: '' %}
{% assign insert_position = product_structured_data.size | minus: last_brace_index | minus: 1 %}
{% assign first_part = product_structured_data | slice: 0, insert_position %}
{% assign last_part = product_structured_data | slice: insert_position, product_structured_data.size %}
{% assign custom_data = first_part | append: ',' | append: rating_data | append: last_part %}
{% else %}
{% assign custom_data = product_structured_data %}
{% endif %}
<script type="application/ld+json">
{{ custom_data }}
</script>
```

Then click **Save** in the code editor.

> **Tip:** Make sure the product.metafields.alireviews.seo_rating_review_key_script metafield actually has a value for the product you're testing. If it's empty, the code above safely falls back to your theme's original structured data and no rating will be added — which usually means the product doesn't yet have Ali Reviews rating data.

## Step 4: Test the result

1. Reopen the product page and check **View page source** again for aggregateRating — it should now be present.
2. Run the page through Google's [Rich Results Test](https://search.google.com/test/rich-results) to confirm the rating is detected.

![](https://storage.crisp.chat/users/helpdesk/website/-/5/1/8/4/51849c8de000cc00/image_1oygxbk.png)
![](https://storage.crisp.chat/users/helpdesk/website/-/5/1/8/4/51849c8de000cc00/image_ebh1uj.png)
## What you might see

* **No rating still appears after editing:** Confirm the product has reviews and that the metafield has a value (see the tip in Step 3). If the metafield is empty, the rating hasn't been generated yet.
* **Google shows a "review" field warning:** Your store needs either Review, AggregateRating, or Offers. Ali Reviews adds AggregateRating, so a suggestion to add a Review field is **optional** and won't affect your rich snippet.
* **Stars don't show in search right away:** Even after everything validates, it can take Google roughly **5–7 days** to re-crawl and display the star ratings in search results.

## Frequently asked questions

**Do I have to edit code for every product?**
No. This edit is made once in your theme's structured data snippet and applies to all product pages that use it.

**Will this break if I update or switch themes?**
Theme updates can overwrite code changes, and a new theme won't include this edit. If you update or change themes, you'll need to reapply this snippet (or re-run the automatic **Rich Snippets → Update** first to see if it works on the new theme).

**Why didn't the automatic integration work on my theme?**
The most common reasons are a custom theme structure that Ali Reviews can't inject into automatically, or another app managing your structured data. This manual method merges the rating directly into your theme's own JSON-LD.

Done! Your custom theme now includes the Ali Reviews rating in its structured data, so Google can display star ratings for your products.

Need help? Reach us via live chat or email at [support@alireviews.io](mailto:support@alireviews.io).