הטמעת ביקורות עם Google Search – Shopify
איך להוסיף קוד קטן (Liquid) שיאפשר לגוגל לסרוק את הביקורות אצלכם באתר ולהוסיף לכם ⭐️⭐️⭐️⭐️☆ (23) בתוצאות חיפוש - זה יכול לעזור לשפר את יחס ההקלקה אליכם ולשפר את מיקומכם תוצאות החיפוש.
איפה ממקמים?
יש להיכנס לעורך התבניות ב Shopify שלכם ולערוך את העמוד theme.liquid
למקם את הקוד מעל לתגית סגירה </head>
הקוד עצמו של Google Search
העתיקו והדביקו את הקוד הזה במיקום שציינו מעלה.
{% if request.page_type == 'product' and product.metafields.flashy.avg_rating and product.metafields.flashy.reviews_count %}
<script>
document.addEventListener("DOMContentLoaded", function () {
const ratingValue = {{ product.metafields.flashy.avg_rating | round: 1 }};
const reviewCount = {{ product.metafields.flashy.reviews_count }};
const structuredData = {
"@type": "AggregateRating",
"ratingValue": ratingValue,
"reviewCount": reviewCount
};
let productSchemaFound = false;
const scripts = document.querySelectorAll("script[type='application/ld+json']");
scripts.forEach(script => {
try {
const data = JSON.parse(script.textContent);
if (Array.isArray(data["@graph"])) {
data["@graph"].forEach(item => {
if (item["@type"] === "Product" || item["@type"] === "ProductGroup") {
item.aggregateRating = structuredData; // Overwrite unconditionally
productSchemaFound = true;
}
});
if (productSchemaFound) {
script.textContent = JSON.stringify(data);
}
} else if (data["@type"] === "Product" || data["@type"] === "ProductGroup") {
data.aggregateRating = structuredData; // Overwrite unconditionally
script.textContent = JSON.stringify(data);
productSchemaFound = true;
}
} catch (e) {
// Ignore parsing errors
}
});
// If no schema was found and updated, inject a new one
if (!productSchemaFound) {
const newData = {
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{ product.title | escape }}",
"image": ["{{ product.featured_image | img_url: 'master' | prepend: 'https:' }}"],
"description": {{ product.description | strip_html | json }},
"sku": "{{ product.selected_or_first_available_variant.sku }}",
"brand": {
"@type": "Brand",
"name": "{{ product.vendor | escape }}"
},
"aggregateRating": structuredData
};
const newScript = document.createElement("script");
newScript.type = "application/ld+json";
newScript.textContent = JSON.stringify(newData);
document.body.appendChild(newScript);
}
});
</script>
{% endif %}
למי שצריך עזרה
אם אינכם בטוחים איפה בדיוק להדביק את הקוד – מומלץ להיעזר במפתח או איש טכני.
בהצלחה✨!