Magento 2 Structured Data Markup: Schema.org and Google Tag Manager
Structured Data Markup and Magento
Your search result rankings can be considerably optimized by using Magento 2 rich snippets or structured data markup. Rich snippets show some additional information about a product, e.g. it's rating, price, photo, availability etc., that's why they are called rich. Such details displayed in your snippet will make it look well presented and will probably be primarily noticed by users.
How Can I Get Magento 2 Rich Snippets?
In order to make more information displayed in your snippets, you have to add structured data markup to your website.
Schema.org is considered to be the best alternative for generating rich snippets. This project was developed by most popular web search engines for providing code examples for particular cases.
Below you can find the detailed instructions on how to configure Magento 2 structured data using Schema JSON-LD method along with Google Tag Manager.
Schema.org And Google Tag Manager
In order to successfully implement structured data markup on your site, it is recommended to use Google Tag Manager. This tool can greatly speed up the process of creating rich snippets as it allows creating tags on different pages using the same piece of code. For example, if you want to specify product price in every page snippet, you can create tag 'Price', so the price will be taken from every product page and displayed in its snippet.
Besides, GTM allows creating variables, e.i. separate URLs or page elements like buttons or headings for dynamic generation of structured data. The relation between a tag and a variable is the following: if the variable meets the conditions of a trigger, the tag will be used.
Add JSON-LD Code to Your Magento 2 Using Google Tag Manager
Here are detailed guides on how to add JSON-LD structured data to your site:
- If you are not sure if you can create JSON-LD code by yourself, it is possible to generate it using Schema JSON-LD Generation Tool. Just select the necessary properties to be included in the markup and copy it to the clipboard.
- Go to Google Tag Manager and create a custom HTML tag and name it.
- Paste the generated code to Custom HTML text box and press 'Save'.
- On the popped-up window, press 'Save tag' button (ignore the message that the trigger is not chosen).
- Add a trigger to the created tag.
- Select its type (Page View) and specify what pages it should fire on.
- Underneath indicate the conditions on which the tag should work.
- Open the custom HTML page you've created on step 2 and choose the trigger for the tag (in our case it is Page View).
In case you want to create the same tag for different pages but make it fire on different conditions, you should create variables for this tag:
- Press 'New' button and name the variable;
- Go to 'Variable' configurations and choose the variable type;
- Add the generated variable to the custom HTML page.
If you select Dom Element type, specify the selection method (CSS Selector in our case), Element selector (for example, H1) and Attribute name.
The implementation of structured data markup to your Magento 2 may seem not so easy, although it can make a great contribution to your SEO. By setting up rich snippets with Google Tag Manager you assist Google in the understanding of when and how to show your pages. That's why it can optimize your positions in search results.