Ecommerce dataLayer per Google Analytics 4

Google Analytics 4

[av_textblock size=” av-medium-font-size=” av-small-font-size=” av-mini-font-size=” font_color=” color=” id=” custom_class=” av_uid=’av-lvmk8n86′ admin_preview_bg=”]
Il livello di dati (o dataLayer) è un oggetto Javascript utilizzato da Google Tag Manager e da gtag.js per trasmettere informazioni ai tag. Gli eventi o le variabili possono essere trasmessi tramite il livello dati e gli attivatori possono essere configurati in base ai valori delle variabili.

Usare un dataLayer ben strutturato è fondamentale anche e soprattutto quando si tratta di un ecommerce perchè questo consentirà di passare in maniera agevole i dati dal sito a tutti i tag interessati, per esempio GA4, Meta, Ads.

Con questo articolo voglio lasciarvi la struttura che dovrebbe avere il dataLayer su un sito ecommerce per essere ben strutturato e completo.

Di seguito le azioni (eventi) da implementare e la relativa struttura del livello dei dati.
[/av_textblock]

[av_toggle_container faq_markup=” initial=’0′ mode=’accordion’ sort=” styling=” colors=” font_color=” background_color=” border_color=” colors_current=” font_color_current=” background_current=” background_color_current=” background_gradient_current_color1=” background_gradient_current_color2=” background_gradient_current_direction=’vertical’ hover_colors=” hover_background_color=” hover_font_color=” alb_description=” id=” custom_class=” av_uid=’av-lvmjsyn3′]
[av_toggle title=’view_item_list’ tags=” custom_id=” av_uid=’av-3kunyv’]
Questo evento dovrebbe apparire quando al visitatore appare una lista di prodotti (o elementi) di una determinata categoria

window.dataLayer = window.dataLayer || [];
window.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: "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.03,
      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
    }]
  }
});

[/av_toggle]
[av_toggle title=’select_item’ tags=” custom_id=” av_uid=’av-2ifs0n1′]
L’evento select_item avviene quando un prodotto è stato selezionato da un elenco. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.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: "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
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’view_item’ tags=” custom_id=” av_uid=’av-2ifs0n2′]
L’evento view_item avviene quando un prodotto viene visualizzato. Utilizza questo evento per scoprire gli articoli più popolari visualizzati. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.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,
      quantity: 3
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’add_to_cart’ tags=” custom_id=” av_uid=’av-2ifs0n3′]
L’evento add_to_cart avviene quando un utente aggiunge un prodotto a carrello. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "add_to_cart",
  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,
      quantity: 3
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’view_cart’ tags=” custom_id=” av_uid=’av-2ifs0n4′]
L’evento view_cart avviene con la visualizzazione del carrello da parte dell’utente. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "view_cart",
  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,
      quantity: 3
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’view_promotion’ tags=” custom_id=” av_uid=’av-2ifs0n5′]
L’evento view_promotion avviene quando una promozione viene visualizzata da un elenco. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.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: "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
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’select_promotion’ tags=” custom_id=” av_uid=’av-2ifs0n6′]
L’evento select_promotion avviene quando una promozione viene selezionata da un elenco. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.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: "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
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’remove_from_cart’ tags=” custom_id=” av_uid=’av-2ifs0n7′]
L’evento remove_from_cart avviene quando un prodotto viene rimosso dal carrello. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "remove_from_cart",
  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,
      quantity: 3
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’add_to_wishlist’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento add_to_wishlist avviene quando un prodotto viene aggiunto alla lista dei desideri. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "add_to_wishlist",
  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,
      quantity: 3
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’begin_checkout’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento begin_checkout avviene quando un utente arriva nel checkout dell’ecommerce. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "begin_checkout",
  ecommerce: {
    currency: "USD",
    value: 30.03,
    coupon: "SUMMER_FUN",
    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
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’add_payment_info’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento add_payment_info avviene quando viene selezionato un metodo di pagamento nel checkout. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "add_payment_info",
  ecommerce: {
    currency: "USD",
    value: 30.03,
    coupon: "SUMMER_FUN",
    payment_type: "Credit Card",
    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
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’add_shipping_info’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento add_shipping_info avviene quando viene selezionato un metodo di spedizione nel checkout. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "add_shipping_info",
  ecommerce: {
    currency: "USD",
    value: 30.03,
    coupon: "SUMMER_FUN",
    shipping_tier: "Ground", //questo è il valore del metodo di spedizione da popolare
    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
    }
    ]
  }
});

[/av_toggle]
[av_toggle title=’purchase’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento purchase avviene quando un utente completa l’acquisto. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.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",
    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
    }]
  }
});

[/av_toggle]
[av_toggle title=’refund’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento refund avviene quando un utente viene rimborsato del suo acquisto. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "refund",
  ecommerce: {
    currency: "USD",
    transaction_id: "T_12345", // Transaction ID. Required for purchases and refunds.
    value: 30.03,
    coupon: "SUMMER_FUN",
    shipping: 3.33,
    tax: 1.11,
    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
    }
    ]
  }
});

[/av_toggle]
[/av_toggle_container]

[av_textblock size=” av-medium-font-size=” av-small-font-size=” av-mini-font-size=” font_color=” color=” id=” custom_class=” av_uid=’av-lvmk8n86′ admin_preview_bg=”]
 
 
Inoltre, nei siti ecommerce o comunque nei siti in cui i visitatori possono iscriversi è importante tracciare anche questi eventi:
[/av_textblock]
[av_toggle_container faq_markup=” initial=’0′ mode=’accordion’ sort=” styling=” colors=” font_color=” background_color=” border_color=” colors_current=” font_color_current=” background_current=” background_color_current=” background_gradient_current_color1=” background_gradient_current_color2=” background_gradient_current_direction=’vertical’ hover_colors=” hover_background_color=” hover_font_color=” alb_description=” id=” custom_class=” av_uid=’av-lvmjsyn3′]
[av_toggle title=’sign_up’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento sign_up avviene quando un utente crea un account nel sito. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "sign_up",
  method: "Google", //il metodo usato per iscriversi al sito
});

[/av_toggle]
[av_toggle title=’login’ tags=” custom_id=” av_uid=’av-2ifs0n8′]
L’evento login avviene quando un utente si collega al sito. Tramite questa azione si potrebbero anche raccogliere le Conversioni avanzate o le Advanced Match, ma questa è un’altra storia. Il dataLayer dovrebbe essere composto in questa maniera:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: "login"
});

[/av_toggle]
[/av_toggle_container]

[av_textblock size=” av-medium-font-size=” av-small-font-size=” av-mini-font-size=” font_color=” color=” id=” custom_class=” av_uid=’av-lvmk8n86′ admin_preview_bg=”]
 
 

Se hai trovato interessante quello che ho raccontato in questo articolo, contattami tramite questo modulo
[/av_textblock]

Hai un problema con il web?

Il tuo sito internet non vuole funzionare?

Vuoi rinnovarlo o sistemarlo?

Hai un’idea di integrazione ma non sai se è possibile realizzarla o meno?

    Accetto la Privacy Policy
    Autorizzo al trattamento dei miei dati personali, per ricevere le informazioni richieste attraverso questo modulo di contatto. I dati da te inseriti attraverso questo modulo verranno utilizzati solo per essere da me ricontattato.

    Recensioni

    Scrivimi una recensione

    Questo QR Code ti permette di lasciarmi una recensione in maniera facile e veloce.

    Altrimenti qui sotto ti lascio un bottone, con il quale puoi lasciare la recensione direttamente su Google My Business.

    Lascia una recensione su Google