המדריך המלא להטמעת דאטהלייר לאיקומרס (GA4)

גוגל אנליטיקס הוא כלי עוצמתי, אבל בלי בסיס נתונים מוצק, הוא רק חצי מהסיפור. הדאטהלייר (שכבת הנתונים) הוא הגשר הקריטי שמחבר בין התנהגות המשתמשים בחנות שלכם לבין התובנות העסקיות שיגרמו לכם לצמוח. במדריך המקיף שלפניכם, נצלול לעומק ההטמעה הטכנית של Google Analytics Ecommerce, ונלמד איך לבנות תשתית נתונים נקייה, מדויקת וחסינה לשינויים שתשרת אתכם שנים קדימה.

במדריך זה נעבור על המבנה הנכון של שכבת הנתונים עבור אירועי האיקומרס המרכזיים ב-Google Analytics 4.


מבנה פריטים (items)

מערך ה-items הוא הלב של מדידת האיקומרס. הוא יכול להכיל עד 200 פריטים. הנה דוגמה למבנה פריט מלא עם כל הפרמטרים החשובים:

  • item_id: מזהה המוצר (מק"ט).
  • item_name: שם המוצר.
  • price: מחיר היחידה.
  • item_category: קטגוריה ראשית (ניתן להוסיף עד 5 רמות קטגוריה).
  • quantity: כמות.

items
items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    },
    {
      item_id: "SKU_12346",
      item_name: "Datalemon Grey Women's Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 3.33,
      index: 1,
      item_brand: "Datalemon",
      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: "gray",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 20.99,
      quantity: 1
    }
]


ניקוי אובייקט ה-ecommerce

לפני שדוחפים אירוע חדש לדאטהלייר, מומלץ מאוד לאפס את אובייקט ה-ecommerce. פעולה זו מונעת מאירועים קודמים בדף להשפיע על האירוע הנוכחי ולהעביר נתונים שגויים.

dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.


אירועי משפך המכירה

בחירת פריט מרשימה (view_item_list)
כאשר מוצגת למשתמש רשימת תוצאות, יש לשלוח אירוע view_item_list הכולל את מערך הפריטים שהוצגו.

view_item_list
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_item_list",
  ecommerce: {
    item_list_id: "related_products",
    item_list_name: "Related products",
    items: [
     {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    },
    {
      item_id: "SKU_12346",
      item_name: "Datalemon Grey Women's Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 3.33,
      index: 1,
      item_brand: "Datalemon",
      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: "gray",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 20.99,
      promotion_id: "P_12345",
      promotion_name: "Summer Sale",
      quantity: 1
    }]
  }
});

בחירת פריט (select_item)
לאחר שהמשתמש בוחר פריט, יש לשלוח אירוע select_item עם הפריט שנבחר.

select_item
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "select_item",
  ecommerce: {
    item_list_id: "related_products",
    item_list_name: "Related products",
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});

צפייה בפרטי פריט (view_item)
כדי למדוד כמה פעמים נצפו פרטי מוצר, שלחו אירוע view_item בכל פעם שמשתמש צופה במסך פרטי הפריט.

view_item
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_item",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});


הוספה או הסרה של פריט מסל הקניות

הוספה לסל: שלחו אירוע add_to_cart עם הפריטים הרלוונטיים.

add_to_cart
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_to_cart",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});

הוספה לרשימת משאלות: ניתן למדוד זאת באמצעות אירוע add_to_wishlist.

add_to_wishlist
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_to_wishlist",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});

צפייה בסל: כאשר המשתמש צופה בסל הקניות, שלחו אירוע view_cart.

view_cart
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_cart",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});

הסרה מהסל: למדידת הסרת פריט, שלחו אירוע remove_from_cart.

remove_from_cart
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "remove_from_cart",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});


תחילת תהליך התשלום (Checkout)

מדדו את השלב הראשון בתהליך התשלום על ידי שליחת אירוע begin_checkout עם פריט אחד או יותר המוגדרים באמצעות השדות הרלוונטיים. ניתן גם להוסיף קופון בשלב זה להזמנה כולה על ידי הוספתו לאירוע או להחיל אותו על פריט מסוים על ידי הוספתו לאלמנטים ספציפיים במערך הפריטים.

begin_checkout
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "begin_checkout",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    coupon: "SUMMER_FUN",
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});

כאשר משתמש ממשיך לשלב הבא בתהליך התשלום ומוסיף פרטי משלוח, יש לשלוח אירוע add_shipping_info. השתמש בפרמטר shipping_tier כדי לציין את אפשרות המשלוח של המשתמש, כגון "post", "self-pickup" או "next day delivary".

add_shipping_info
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_shipping_info",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    coupon: "SUMMER_FUN",
    shipping_tier: "Ground",
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});

שלחו את האירוע add_payment_info כאשר משתמש שולח את פרטי התשלום שלו. אם רלוונטי, כללו את payment_type באירוע זה עבור שיטת התשלום שנבחרה.

add_payment_info
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "add_payment_info",
  ecommerce: {
    currency: "USD",
    value: 7.77,
    coupon: "SUMMER_FUN",
    payment_type: "Credit Card",
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});


ביצוע רכישה או הנפקת החזר (Refund)

מדדו רכישה על ידי שליחת אירוע purchase עם פריט אחד או יותר המוגדרים בשדות הרלוונטיים.

purchase
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "purchase",
  ecommerce: {
      transaction_id: "T_12345",
      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: "Datalemon Merchandise Store",
        coupon: "SUMMER_FUN",
        discount: 2.22,
        index: 0,
        item_brand: "Datalemon",
        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
      },
      {
        item_id: "SKU_12346",
        item_name: "Datalemon Grey Women's Tee",
        affiliation: "Datalemon Merchandise Store",
        coupon: "SUMMER_FUN",
        discount: 3.33,
        index: 1,
        item_brand: "Datalemon",
        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: "gray",
        location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
        price: 20.99,
        promotion_id: "P_12345",
        promotion_name: "Summer Sale",
        quantity: 1
      }]
  }
});


מדדו החזרים על ידי שליחת אירוע refund עם ה-transaction_id הרלוונטי שצוין ופריט אחד או יותר מוגדרים עם item_id ו-quantity. אנו ממליצים לכלול פרטי פריט באירוע ההחזר שלכם כדי לראות מדדי החזר ברמת הפריט באנליטיקס.

refund
dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object.
dataLayer.push({
event: "refund",
ecommerce: {
currency: "USD",
transaction_id: "T_12345", // Transaction ID. Required for purchases and refunds.
value: 12.21,
coupon: "SUMMER_FUN",
shipping: 3.33,
tax: 1.11,
items: [
{
item_id: "SKU_12345",
item_name: "Stan and Friends Tee",
affiliation: "Datalemon Merchandise Store",
coupon: "SUMMER_FUN",
discount: 2.22,
index: 0,
item_brand: "Datalemon",
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
}
]
}
});


החלת מבצעים (Promotions)

איקומרס כולל תמיכה במדידת חשיפות וקליקים של מבצעים פנימיים, כגון באנרים המוצגים לקידום מכירה.

חשיפות של מבצעים נמדדות בדרך כלל עם תצוגת המסך הראשונית על ידי שליחת האירוע view_promotion עם פרמטר items כדי לציין את הפריט המקודם.

view_promotion
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_promotion",
  ecommerce: {
    creative_name: "Summer Banner",
    creative_slot: "featured_app_1",
    promotion_id: "P_12345",
    promotion_name: "Summer Sale",
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});

כדי לציין שמשתמש לחץ על מבצע, שלחו אירוע select_promotion עם הפריט כפרמטר של items. לפרטים על הפרמטרים שיש לשלוח.

select_promotion
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "select_promotion",
  ecommerce: {
    creative_name: "Summer Banner",
    creative_slot: "featured_app_1",
    promotion_id: "P_12345",
    promotion_name: "Summer Sale",
    items: [
    {
      item_id: "SKU_12345",
      item_name: "Stan and Friends Tee",
      affiliation: "Datalemon Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 2.22,
      index: 0,
      item_brand: "Datalemon",
      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
    }
    ]
  }
});


שימוש במשתנה JavaScript מותאם אישית

אם האתר אינו תומך בדאטהלייר, תוכלו להשתמש במשתנה JavaScript מותאם אישית כדי לקרוא לפונקציה שמחזירה את אובייקט הנתונים של ecommerce. אובייקט זה צריך להשתמש ב-syntax הדאטהלייר המוצג קודם לכן במדריך זה; לדוגמה:

// A Custom JavaScript Variable that returns an ecommerceData object
// that follows the data layer syntax.
function getEcommerceData() {
  var ecommerceProductData = [
    {
      item_name: "Stan and Friends Tee",
      item_id: "SKU_12345",  // ID is required.
      // Rest of the product data should follow the data layer syntax.
    },
    // Multiple products may be included.
  ];
  return ecommerceProductData;
}

אם תבחרו להשתמש במשתנה JavaScript מותאם אישית, תוכלו להשתמש בו באותו אופן שבו הייתם משתמשים בדאטהלייר – תוכלו לספק את הערך מהפרמטר 'items' כפרמטר אירוע בקונפיגקציית התג שלכם.

קונפיגרציה :

  • סוג תג: GA4 Event
  • שם אירוע: any
  • קריאת נתונים ממשתנה: {{gaEcommerceData}}
  • טריגר: event equals gtm.dom

הגדרות משתנה gaEcommerceData

  • סוג משתנה: Custom JavaScript
  • גוף הפונקציה: השתמש בדוגמה שלמעלה

הערה: תצורת התג לדוגמה משתמשת ב-DOM Ready ‏(gtm.dom) כדי להפעיל את תג האירוע של אנליטיקס. עליכם להשתמש ב-DOM Ready כאשר ברצונכם לטעון את כל האלמנטים בדף לפני שליחת אירוע, כך שתוכלו להחזיר ערכים מ-Document Object Model (DOM). לדוגמה, תוכל להשתמש ב-DOM Ready עבור האירוע view_item_list כך שהפריטים שמישהו צופה בהם ייטענו לפני שליחת האירוע.

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

תפריט נגישות

🍪 האתר עושה שימוש בעוגיות

אנחנו משתמשים בקובצי Cookie כדי להתאים אישית תוכן ומודעות, לספק תכונות של מדיה חברתית ולנתח את תנועת המשתמשים שלנו. בנוסף, אנחנו משתפים מידע על אופן השימוש באתר שלנו עם השותפים שלנו מתחומי המדיה החברתית, הפרסום וניתוח הנתונים. גורמים אלה עשויים לשלב את הנתונים האלה עם מידע אחר שסיפקתם או שהם אספו בעקבות השימוש שעשיתם בשירותים שלהם.