Wróć do bloga
GA4
dataLayer
E-commerce

GA4 Enhanced E-commerce z dataLayer — kompletny przewodnik

Jak poprawnie wdrożyć Enhanced E-commerce w GA4 bez wtyczek? Schemat zdarzeń dataLayer dla view_item, add_to_cart i purchase.

15 listopada 202412 min czytaniaDaniel Kruszewski

Dlaczego dataLayer, a nie wtyczka?

Wtyczki WooCommerce dla GA4 przestają działać po aktualizacji WordPressa. dataLayer jest standardem Google — działa niezależnie od CMS.

Schemat zdarzeń GA4 e-commerce — przepływ danych przez dataLayer

Schemat zdarzeń

view_item

// Źródło: https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "view_item",
  ecommerce: {
    currency: "USD",
    value: 30.03,
    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: 10.01,
      google_business_vertical: "retail",
      quantity: 3
    }
    ]
  }
});

purchase

// Źródło: https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtm
dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object.
dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "T_12345",
    // Sum of (price * quantity) for all items.
    value: 72.05,
    tax: 3.60,
    shipping: 5.99,
    currency: "USD",
    coupon: "SUMMER_SALE",
    customer_type: "new",
    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: 10.01,
      quantity: 3
    },
    {
      item_id: "SKU_12346",
      item_name: "Google Grey Women's Tee",
      affiliation: "Google Merchandise Store",
      coupon: "SUMMER_FUN",
      discount: 3.33,
      index: 1,
      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: "gray",
      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
      price: 21.01,
      promotion_id: "P_12345",
      promotion_name: "Summer Sale",
      quantity: 2
    }]
  }
});

Konfiguracja GTM

Używamy triggera Custom Event z nazwą zdarzenia z dataLayer. Zmienna ecommerce pobiera dane przez Data Layer Variable z kluczem ecommerce.

Potrzebujesz pomocy z wdrożeniem?

Mogę skonfigurować to dla Ciebie — od audytu do gotowego wdrożenia.

Firmy, z którymi współpracuję

Logo Carpeto
Logo CrazyShop
Logo PartyBox
Logo Utile.pl
Logo Seniorze.pl
Logo Beautiona
Logo Semavo
Logo Marketize
Logo eighteen studio
Logo Hapies
Logo Arting
Logo Novacon
Logo Lamele3D
Logo GardenJoy
Logo Carpeto
Logo CrazyShop
Logo PartyBox
Logo Utile.pl
Logo Seniorze.pl
Logo Beautiona
Logo Semavo
Logo Marketize
Logo eighteen studio
Logo Hapies
Logo Arting
Logo Novacon
Logo Lamele3D
Logo GardenJoy
NapiszKonsultacja