אם אתם רוצים לעקוב אחרי כל ההמרות שלכם, אתם יכולים להגדיר אירועי רכישה באתר ולקשר אותם אל Merchant Center. המאמר הזה מסביר איך להגדיר אירועי רכישה באתר שלכם.
איך זה עובד
כדי לאסוף נתוני המרות, צריך לעקוב אחרי אירועי רכישה באתר. כדי לעקוב אחרי האירועים האלה צריך להגדיר אותם באתר.
בהמשך מוצגות שתי דוגמאות שממחישות איך אירוע רכישה עשוי להישלח מהאתר שלכם.
דוגמה ראשונה: אירוע רכישה שנשלח כשפותחים את הדף
צריך להציב את אירוע הרכישה בדף שבו מתבצעת הרכישה באתר. למשל, אפשר להוסיף את האירוע לדף האישור שמופיע אחרי שאנשים מבצעים רכישה. המדריך הזה מסביר איך להוסיף את האירוע לדף שבו אנשים לוחצים על לחצן לביצוע רכישה.
מציבים את האירוע בתג <script> בסוף התג <body>. הצבת האירוע ישירות בתג <script> תגרום לשליחת האירוע כשהדף נטען.
קוד לדוגמה
<!--
הערה: בקוד לדוגמה הבא, אתם צריכים
להחליף את 'TAG_ID' במזהה התג שלכם.
למידע נוסף: https://support.google.com/tagmanager/answer/12326985
-->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
</head>
<body>
<div>כאן יופיע טופס הרכישה</div>
<button>Submit</button>
<script>
gtag("event", "purchase", {
transaction_id: "T_12345_1",
affiliation: "Google Merchandise Store",
value: 25.42,
tax: 4.90,
shipping: 5.99,
currency: "USD",
coupon: "SUMMER_SALE",
items: [
// אם מישהו קונה יותר מפריט אחד,
// אפשר להוסיף את הפריטים האלה למערך הפריטים
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
discount: 2.22,
index: 0,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "green",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 9.99,
quantity: 1
}]
});
</script>
</body>
</html>
דוגמה שנייה: אירוע רכישה שנשלח כשלוחצים על לחצן
יש כמה דרכים שבהן אפשר להגדיר את אירוע הרכישה כך שיישלח ברגע שאנשים לוחצים על לחצן לביצוע רכישה. אחת הדרכים היא להוסיף מזהה ללחצן לביצוע הרכישה ואחר כך להציב את קוד האירוע בתוך event listener. בדוגמה הבאה, האירוע נשלח רק כאשר לוחצים על לחצן עם מזהה הרכישה.
קוד לדוגמה
<!--
הערה: בקוד לדוגמה הבא, אתם צריכים
להחליף את 'TAG_ID' במזהה התג שלכם.
למידע נוסף: https://support.google.com/tagmanager/answer/12326985
-->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
</head>
<body>
<div>כאן יופיע טופס הרכישה</div>
<button id="purchase">Purchase</button>
<script>
document.getElementById("purchase").addEventListener("click", function () {
gtag("event", "purchase", {
// באירוע הרכישה הזה יש מזהה עסקה שונה
// ממזהה הרכישה הקודם כדי שמערכת Analytics
// לא תבטל את כפילות האירועים.
// למידע נוסף: https://support.google.com/analytics/answer/12313109
transaction_id: "T_12345_2",
affiliation: "Google Merchandise Store",
value: 25.42,
tax: 4.90,
shipping: 5.99,
currency: "USD",
coupon: "SUMMER_SALE",
items: [
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee",
affiliation: "Google Merchandise Store",
coupon: "SUMMER_FUN",
discount: 2.22,
index: 0,
item_brand: "Google",
item_category: "Apparel",
item_category2: "Adult",
item_category3: "Shirts",
item_category4: "Crew",
item_category5: "Short sleeve",
item_list_id: "related_products",
item_list_name: "Related Products",
item_variant: "green",
location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
price: 9.99,
quantity: 1
}]
});
});
</script>
</body>
</html>
קישור אירועי רכישה אל Merchant Center
אתם יכולים לקשר אירועי רכישה אל Merchant Center באמצעות מקורות של המרות.
איך להוסיף מקורות של המרות ב-Merchant Center.