console.warn && console.warn("[GTM4WP] Google Tag Manager container code placement set to OFF !!!"); console.warn && console.warn("[GTM4WP] Data layer codes are active but GTM container must be loaded using custom coding !!!");

Blog Fast White Cat

Implementing Rich Snippets Using Markup in Magento

Non Agency May 24. 2024
Rich snippets - rating stars in Magento markup is necessary for search engines to display rich snippets, which include images, breadcrumbs, reviews, and opening hours.

This enhancement makes your website more appealing and can lead to an increase in people clicking through to your site.

However, according to the 2017 study by Bing and Catalyst, only 17% of marketers use markup.

Part of why that's the case is that marketers often find it challenging to integrate this solution into their processes properly.

We're here to help you overcome this obstacle.

Below, you'll find a detailed guide on how to add rich snippets to Magento using markup.

Let's get started.

Key Takeaways

  • Identify essential properties for your Magento products and add them using HTML microdata attributes.

  • Set the 'itemscope' attribute to define the scope of product items on your Magento product pages.

  • Include detailed product information like name, description, and image using tags to enhance rich snippet accuracy.

  • Use Google's Rich Results Test tool to validate the implementation and visibility of structured data in Magento.

  • Extend Magento's default markup to include additional product details for a more comprehensive display in search results.

What Are Tags tags are structured microdata that you can implement on your Magento product pages to enhance the visibility and detail of your listings in search engine results.

By embedding this microdata into your HTML, you provide search engines like Google, Bing, and Yahoo with explicit clues about the meaning of your page content.

This structured format is important because it helps these search engines understand the specifics of your products, which, in turn, improves how your products are indexed and displayed in search results.

So, if you want to move up in Google search results, adding rich snippets is an excellent decision.

Benefits of Adding Rich Snippets to Magento

As we mentioned before, integrating tags on your Magento site enables rich snippets in search results, which can greatly enhance click-through rates.

Rich snippets display a preview of your product's information directly in search results, providing potential customers with valuable information like star ratings, price, and stock status before they even click on your link.

Additionally, markup is becoming increasingly important with the growth of voice search. It serves as a guide for digital assistants, helping them find and deliver the correct information in response to voice queries.

Voice search often relies on context that may not be explicitly stated in the text on a page. Schema markup adds this context, making it easier for digital assistants to understand and respond accurately to user inquiries.

Using a Magento 2 rich snippets extension or optimizing your schema markup by hand might soon become a necessity rather than a convenient way to improve one's search engine rankings.

Implementing Microdata in Magento

Implementing markup is easier said than done.

Even with the help of tools like Google's Structured Data Markup Helper or a dedicated extension, you may find yourself overwhelmed and confused.

To effectively implement microdata in your Magento store, you'll need to start by adding specific schema tags to your product pages. This technical setup involves understanding and applying vocabulary to enhance your product listings on search engines.

Here's how you can go about it:

  1. Identify Essential Properties: Determine the most relevant properties for your products. Common properties include `name,` `price,` `image,` and `availability.`

  2. Add Microdata to HTML: Wrap your product attributes in `<span>` or `<div>` tags with the appropriate `itemprop` attribute. For example, `<span itemprop='name'>Product Name</span>` helps search engines recognize the product's name.

  3. Test and Validate: Use tools like Google's Rich Results Test to make sure your microdata is correctly implemented and recognized by search engines.

While that's the general gist of the idea, you may need more specific instructions to configure your product rich snippets. In the following sections, we'll go over some examples to help you get the hang of it.

Setting up a Product Item Scope

Let's begin with setting up a product item scope. During this step, it's important to include specific attributes that help define the product according to structured data standards.

Here's how you can do this using HTML markup and PHP.

First, start by identifying the main container of your product with an 'itemscope' and specify specify it is a product type. This is done in the HTML div tag. For example:

<div class="product-view" itemscope itemtype="" itemid="#product_base">

Here, `itemtype` specifies that the content inside is about a product. `itemid` can be used to connect this product with related sub-products or offers, but it's optional for simple products.

Next, focus on key elements like the product name and short description. These should be marked clearly so search engines can identify them easily.

For declaring the product name, use an `<h1>` tag with 'itemprop="name"'. It might look something like this:

<h1 itemprop="name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>

For a short description of the product, use a div tag. Here's how you can do it:

<div class="std" itemprop="description"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>

These snippets pull data using PHP and display it within your HTML, making sure each piece is correctly labeled with `itemprop` tags that help define what each element represents (like 'name' and 'description').

Lastly, you can also include other metadata information, such as the product URL and SKU, using `meta` tags within the same itemscope:

<meta itemprop="url" content="<?php echo $_product->getUrlModel()->getUrl($_product, array('_ignore_category'=>true)); ?>" />
<meta itemprop="sku" content="<?php echo $_product->getSku() ?>" />

These `meta` tags are crucial for providing search engines with additional details that aren't visible to users but are essential for SEO and product identification.

  • The `url` tag ensures the product's direct link is indexed

  • The `sku` tag gives its stock-keeping unit code, which is useful for inventory and listing purposes.

Customizing Magento Product Attributes

After implementing basic microdata in your Magento store, you'll need to customize product attributes to optimize your site's schema markup further.

Adding the Product Image Property

One of the first things you should focus on is declaring the product image.

It's important to guarantee images are marked up correctly, as they play a significant role in search visibility and user engagement.

If you need to update the product image in your website's theme, head over to the media.phtml file located at:

- app/design/frontend/[package]/[theme]/template/catalog/product/view

Here, the critical changes involve adjusting specific lines of code — specifically, Line 40 and Line 62.

On Line 40, the image tag looks like this:

$_img = ‘<img itemprop=”image” id=”image” src=”‘.$this->helper(‘catalog/image’)->init($_product, ‘image’).’” alt=”‘.$this->escapeHtml($this->getImageLabel()).’” title=”‘.$this->escapeHtml($this->getImageLabel()).’” />';

This line assigns an "id" attribute to the image and includes necessary attributes like src, alt, and title based on the product details. The 'id' helps identify this image element on the page.

Then, moving to Line 62, you'll notice a slight variation:

$_img = ‘<img itemprop=”image” src=”‘.$this->helper(‘catalog/image’)->init($_product, ‘image’).’” alt=”‘.$this->escapeHtml($this->getImageLabel()).’” title=”‘.$this->escapeHtml($this->getImageLabel()).’” />';

In this instance, the code is almost identical, except there is no "id" attribute. It could be used when image identification within a script or style is unnecessary.

Both lines employ helpful functions to dynamically fetch and display the correct image, relying on Magento's built-in tools to ensure everything displays as intended based on your theme and settings.

Always double-check which attributes are necessary for your current design and functionality requirements.

Adding Price and Availability

Setting up a basic product page also involves specifying details like price and availability. This is essential for organizing product information effectively, especially when dealing with different types of products.

To start, open the file at:


Begin by introducing an Offer Itemscope in your code. This starts on Line 28, as shown below:

<div itemprop="offers" itemscope itemtype="">…</div>

This structure lays the foundation for specifying offers related to the product.

Next, identify the currency of the product's price on Line 30 by adding a Meta tag. It uses PHP to retrieve the current store's currency setting dynamically:

<meta itemprop="priceCurrency" content="<?php echo Mage::app()->getStore()->getCurrentCurrencyCode();?>"/>

Moving forward, set up indicators for product availability.

This can be done using links embedded within conditional PHP statements on Lines 34 and 36. These lines check if the product is in stock and display relevant information accordingly:

<?php if ($_product->isAvailable()): ?>
<p class="availability in-stock">
<link itemprop="availability" href=""/>
<?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span>
<?php else: ?>
<p class="availability out-of-stock">
<link itemprop="availability" href=""/>
<?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span>
<?php endif; ?>

These snippets enhance the user interface by clearly indicating whether the product can be purchased immediately or if it's unavailable.

Magento 2 Rich Snippets Integration

Magento 2 includes a basic setup for product rich snippets by default.

Yet, this setup often misses several elements, such as the number of reviews, brand information, and images.

Because of that, many Magenta 2 users opt to remove the default microdata before using other extensions to add rich snippets structured data.

Our experts at Fast White Cat can help you with Magento implementations, making sure your store delivers excellent sales results.

If you want to avoid the hassle of setting up and maintaining your Magento eCommerce store, we'll happily do it for you!

Testing Rich Snippets Implementation

Before launching your updated Magento site, you should test the rich snippets implementation to ensure search engines accurately index them. The microdata you've integrated into your product pages should be detectable and properly structured.

There are many structured data testing tools you can use.

We recommend using Google's Rich Results Test tool. This tool allows you to either submit a URL or paste code to check for structured data visibility and errors.

You'll see which rich snippets are eligible for enhancement in search results and get detailed feedback on any issues found within your code.

Add Rich Snippets to Magento 2 Pages With Ease

Now that you've explored the essentials of implementing rich snippets using in Magento, you're ready to enhance your product visibility on search engines.

By customizing product attributes and utilizing Magento 2's schema features, you can guarantee your product listings are accurately marked up.

And if you need help making your Magento rich snippets stand out, contact us! We'll be more than happy to help your business achieve its true potential.


1. What are rich snippets, and how do they work?

Rich snippets provide additional information to search engines about your website content, helping them display more detailed search results. They use structured data markup from to enhance the appearance of search results.

2. How can I implement rich snippets in Magento?

You can use structured data markup to implement rich snippets in Magento. There are extensions available that can help you add the necessary markup to your Magento store so that rich snippets appear in search results.

3. What are the benefits of using rich snippets in Magento?

Using rich snippets in Magento can improve the visibility of your website in search engine results pages, drive more traffic to your online store, and make it easier for search engines to understand the content of your site.

4. How do I configure rich snippets for products in Magento?

You can configure rich snippets for products in Magento by adding structured data markup specific to the product schema. This will include details like product price, availability, and other relevant information.

5. Can I use rich snippets for other types of content in Magento besides products?

You can use rich snippets for various types of content in Magento, such as FAQs and category pages. Each type of content may require different structured data markup.

6. How do I verify if my rich snippets are implemented correctly?

You can use tools like the Google Structured Data Testing Tool to verify everything is set up correctly. This tool will check the structured data markup on your pages and provide feedback on any errors or issues.

    Check how we can improve your business