Reporting Analytical Statistics - ecellar/remote-widgets GitHub Wiki

The eCellar Designer Widget system is capable of providing robust consumer interaction data to Google Analytics 4 and/or Facebook Pixel to help you see and understand your consumer behavior.

It is straight-forward to enable these in your Initialization Options by including a stats object, though some additional configuration is recommended in Google Analytics and required for Google Tag Manager.

epubOptions = {
  APIKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
  pathRoot: '/shop/',
  stats: {ga4gtag: true}
}

The example above instructs Designer Widgets to provide data to Google Analytics 4 using a simple Google Tag (not Google Tag Manager). This is the modern, simple, way of implementing Google Analytics 4. We also support passing data through Google Tag Manager with ga4gtm: true. You should only use ONE of these for sending data to Google Analytics 4. Facebook pixel is enabled with fbq: true. While it may be possible to map data from Google Tag Manager into Facebook Pixel, we are not able to help you configure GTM for that.

Prerequisites

You have already installed the base tracking code on all Designer Widget enabled pages to collect page view statistics. Confirm page view statistics are appearing in your destination (Google Analytics 4 / Facebook Pixel).

Section Links

Google Analytics 4 Stand Alone

You should already have page view statistics showing for your Google Analytics 4 property. The google tracking code on your website should look like this:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
   gtag('config', 'G-XXXXXXXXXX');
  </script>

To get even more information from your DW installation enable additional events by adjusting the DW config to include {stats: ga4gtag: true}.

epubOptions = {
  APIKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
  pathRoot: '/shop/',
  stats: {ga4gtag: true}
}

To receive “page view” statistics for dynamic page changes within Designer Widgets, confirm the Data Stream for your Website is configured to enable “Enhanced Measurement” → “Page Views” → “Page changes based on browser history events”. Find this setting in the “Admin” within Google Analytics.
Google Analytics 4 Setup - Enhanced Measurement

To track “Create Account”, “Join List” and “Join Club” events as “Conversions”, find or create an Event named “sign_up” and toggle that to enable it as a Conversion metric.
Google Analytics 4 Setup - sign_up Event

To track “Create Subscription” events for existing customers as “Conversions”, find or create an Event named “join_group” and toggle that to enable it as a Conversion metric.
Google Analytics 4 Setup - join_group Event

To track “Reservation Requested” events as “Conversions”, find or create Events named “reservation” and “reservation_with_purchase” and toggle that to enable it as a Conversion metric.
Google Analytics 4 Setup - reservation Event

Designer Widgets will now report the following information via recommended GA4 events:

  • Cart Add / Remove / Update (with product sku, quantity and name)
  • Product Impressions (with product category, sku, name, price and position)
  • Product Detail Impressions (with product sku, name and price)
  • Checkout Start (with product sku, quantity, name and price)
  • Checkout Steps (Delivery and Payment Method)
  • Checkout Complete (with total, tax, shipping, and product sku, quantity, name and price)
  • Dynamic “page” view changes
  • Account Created
  • Join List Completed
  • Wine Club Join Completed (with tier name)
  • Customer Create Club Subscription (with tier name)
  • Reservation Requested (with purchase data)

You may see some of the statistics immediately in the real time reporting, though some things are delayed (in Google Analytics) by up to 24 hours.

Google Analytics 4 via Google Tag Manager

You should already have page view statistics showing for your Google Analytics 4 property. The google tracking code on your website should look like this:

  <!-- Google Tag Manager -->
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer','GTM-XXXXXXX');</script>

To get even more information from your DW installation you’ll need to enable additional events by adjusting the DW config to include {stats: ga4gtm: true} as well as perform some necessary configuration in both Google Analytics and Google Tag Manger.

epubOptions = {
  APIKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
  pathRoot: '/shop/',
  stats: {ga4gtm: true}
}

Begin by configuring the following within Google Analytics for your GA4 property:

To receive “page view” statistics for dynamic page changes within Designer Widgets, confirm the Data Stream for your Website is configured to enable “Enhanced Measurement” → “Page Views” → “Page changes based on browser history events”. Find this setting in the “Admin” within Google Analytics.
Google Analytics 4 Setup - Enhanced Measurement

To track “Create Account”, “Join List” and “Join Club” events as “Conversions”, find or create an Event named “sign_up” and toggle that to enable it as a Conversion metric.
Google Analytics 4 Setup - sign_up Event

To track “Create Subscription” events for existing customers as “Conversions”, find or create an Event named “join_group” and toggle that to enable it as a Conversion metric.
Google Analytics 4 Setup - join_group Event

To track “Reservation Requested” events as “Conversions”, find or create Events named “reservation” and “reservation_with_purchase” and toggle that to enable it as a Conversion metric.
Google Analytics 4 Setup - reservation Event

Create the Variables, Triggers and Tags in Google Tag Manager

You’ll need to create a Variable for each piece of data in the Google Analytics 4 recommended events so they can be passed through in the tags:

  • currency
  • value
  • items
  • item_list_name
  • shipping
  • tax
  • transaction_id
  • method
  • group_id
  • location
  • number_tasting
  • party_size
  • reservation_start
  • reservation_end
  • reservation_id
  • reservation_type
  • station

You’ll also want to create a Variable with your GA4 tag id so you don’t have to enter it manually for every tag later, we’ll start with that:

Open Google Tag Manager and navigate to “Variables” display. Click the button to create a new “User-Defined Variable.”
Google Tag Manager Variables - New User Defined Variable

Name the User-Defined Variable something easily identifiable for the GA4 property, we used “eCELLAR Test GA4”, choose type “Constant”.
Google Tag Manager Variables - GA4 Tag Id Variable

Enter the tag id of your GA4 property (format like G-XXXXXXXXXX) and click save.
Google Tag Manager Variables - GA4 Tag Id Variable

Now, begin creating the Data Layer Variables starting with currency. Click the New button again and name the User-Defined Variable “dlv – currency”, choose type “Data Layer Variable” with name “currency” and save.
Google Tag Manager Variables - Currency Variable

Repeat for the “value” variable.
Google Tag Manager Variables - Value Variable

Repeat for the “items” variable.
Google Tag Manager Variables - Items Variable

Repeat for the “item_list_name” variable.
Google Tag Manager Variables - Item List Name Variable

Repeat for the “shipping” variable.
Google Tag Manager Variables - Shipping Variable

Repeat for the “tax” variable.
Google Tag Manager Variables - Tax Variable

Repeat for the “transaction_id” variable.
Google Tag Manager Variables - Transaction ID Variable

Repeat for the “method” variable.
Google Tag Manager Variables - Method Variable

Repeat for the “group_id” variable.
Google Tag Manager Variables - Group ID Variable

Repeat for the “location” variable.
Google Tag Manager Variables - Location Variable

Repeat for the “number_tasting” variable.
Google Tag Manager Variables - Number Tasting Variable

Repeat for the “party_size” variable.
Google Tag Manager Variables - Party Size Variable

Repeat for the “reservation_start” variable.
Google Tag Manager Variables - Reservation Start Time Variable

Repeat for the “reservation_end” variable.
Google Tag Manager Variables - Reservation End Time Variable

Repeat for the “reservation_id” variable.
Google Tag Manager Variables - Reservation ID Variable

Repeat for the “reservation_type” variable.
Google Tag Manager Variables - Reservation Type Variable

Repeat for the “station” variable.
Google Tag Manager Variables - Station Variable

You should now have the following User-Defined Variables:
Google Tag Manager Variables - List of all Variables

Next, you’ll create Triggers for all the events you want to pass along to Google Analytics 4:

  • view_item_list
  • view_item
  • add_to_cart
  • remove_from_cart
  • begin_checkout
  • add_shipping_info
  • add_payment_info
  • purchase
  • sign_up
  • join_group
  • reservation
  • reservation_with_purchase

Navigate to “Triggers” and click the “New” button.
Google Tag Manager Triggers - Create New

Name the Trigger “eCELLAR Event – List View” and choose “Custom Event” as the Trigger Type.
Google Tag Manager Triggers - Choose Custom Event Type

Use event name “view_item_list” for all custom events and save.
Google Tag Manager Triggers - view_item_list

Repeat for “view_item” trigger.
Google Tag Manager Triggers - view_item

Repeat for “add_to_cart” trigger.
Google Tag Manager Triggers - add_to_cart

Repeat for “remove_from_cart” trigger.
Google Tag Manager Triggers - remove_from_cart

Repeat for “begin_checkout” trigger.
Google Tag Manager Triggers - begin_checkout

Repeat for “add_shipping_info” trigger.
Google Tag Manager Triggers - add_shipping_info

Repeat for “add_payment_info” trigger.
Google Tag Manager Triggers - add_payment_info

Repeat for “purchase” trigger.
Google Tag Manager Triggers - purchase

Repeat for “sign_up” trigger.
Google Tag Manager Triggers - sign_up

Repeat for “join_group” trigger.
Google Tag Manager Triggers - join_group

Repeat for “reservation” trigger.
Google Tag Manager Triggers - reservation

Repeat for “reservation_with_purchase” trigger.
Google Tag Manager Triggers - reservation_with_purchase

You should now have the following Triggers:
Google Tag Manager Triggers - List of all Triggers

Using the Variables and Triggers created above, you’ll create Tags for each event you want to send to Google Analytics 4 with the appropriate data:

  • view_item_list
  • view_item
  • add_to_cart
  • remove_from_cart
  • begin_checkout
  • add_shipping_info
  • add_payment_info
  • purchase
  • sign_up
  • join_group
  • reservation

Navigate to “Tags” and click the “New” button.
Google Tag Manager Tags - Create New

Name the Trigger “eCELLAR – List View” and choose “Google Analytics: GA4 Event” as the Tag Type.
Google Tag Manager Tags - Choose GA4 Event Type

Select the User Defined Variable with the Constant value of the Tag ID for your Google Analytics 4 property.
Google Tag Manager Tags - Choose GA4 Tag ID variable

Set Event Name to “item_list_view”, add Event Parameters for “items” and “item_list_name” then check “Send Ecommerce Data” under More Settings.
Google Tag Manager Tags - Set Event Parameters

Add the List View trigger created earlier and save.
Google Tag Manager Tags - Set Trigger

Repeat for “view_item” using “items” parameter and appropriate Trigger.
Google Tag Manager Tags - View Item

Repeat for “add_to_cart” using “items”, “currency” and “value” parameters and appropriate Trigger.
Google Tag Manager Tags - Add to Cart

Repeat for “remove_from_cart” using “items”, “currency” and “value” parameters and appropriate Trigger.
Google Tag Manager Tags - Remove from Cart

Repeat for “begin_checkout” using “items”, “currency” and “value” parameters and appropriate Trigger.
Google Tag Manager Tags - Begin Checkout

Repeat for “add_shipping_info” using no parameters and no ecommerce data with the appropriate Trigger.
Google Tag Manager Tags - Add Shipping Info

Repeat for “add_payment_info” using no parameters and no ecommerce data with the appropriate Trigger.
Google Tag Manager Tags - Add Payment Info

Repeat for “purchase” using “items”, “currency”, “shipping”, “tax”, “transaction_id”, and “value” parameters and appropriate Trigger.
Google Tag Manager Tags - Purchase

Repeat for “sign_up” using “method” parameter and appropriate Trigger.
Google Tag Manager Tags - Signup

Repeat for “join_group” using “group_id” parameter and appropriate Trigger.
Google Tag Manager Tags - Join Group

Repeat for “reservation” using new “ReservationData” parameter and appropriate Trigger.
Google Tag Manager Tags - Reservation Requested

Include the reservation data by creating a new variable with all the data layer variables
Google Tag Manager Tags - Reservation Requested

You should now have the following Tags:
Google Tag Manager Tags - List of all Tags

FINALLY, we can Preview, Submit, and PUBLISH the changes to our GTM Workspace.

Save
GTM - Save workspace changes

Publish
GTM - Publish workspace changes

Designer Widgets will now report the following information via recommended GA4 events:

  • Cart Add / Remove / Update (with product sku, quantity and name)
  • Product Impressions (with product category, sku, name, price and position)
  • Product Detail Impressions (with product sku, name and price)
  • Checkout Start (with product sku, quantity, name and price)
  • Checkout Steps (Delivery and Payment Method)
  • Checkout Complete (with total, tax, shipping, and product sku, quantity, name and price)
  • Dynamic “page” view changes
  • Account Created
  • Join List Completed
  • Wine Club Join Completed (with tier name)
  • Reservation Requested (with purchase data)

You may see some of the statistics immediately in the real time reporting, though some things are delayed (in Google Analytics) by up to 24 hours.

Facebook Pixel

You should already have page view statistics showing in Facebook Pixel, to get even more information from your DW installation enable additional events by adjusting the config for DW to include {stats: fbq: true}.

epubOptions = {
  APIKey: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
  pathRoot: '/shop/',
  stats: { fbq: true}
}

Designer Widgets will now report the following information via pixel standard events:

  • Cart Add / Remove / Update (with product sku and quantity)
  • Checkout Start (with product skus and quantities)
  • Checkout Complete (with total and product skus and quantities)
  • Account Created
  • Join List Completed
  • Wine Club Join Completed
  • Dynamic “page” view changes
⚠️ **GitHub.com Fallback** ⚠️