magepal / magento2-google-tag-manager

Google Tag Manager is a user-friendly, yet powerful and cost-effective solution that is a must-have integration for every Magento store. It simplifies the process of adding and managing third-party JavaScript tags. With dozens of custom events and hundreds of data points our extensions the #1 GTM solution for Magento.

Home Page:https://www.magepal.com/google-tag-manager.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ecommerce data don't pass to GA

mykhailo-superiorseating opened this issue · comments

Magento version #: 2.3.1

Edition (EE, CE, OS, etc): CE

Expected behavior:

New orders pass to GA at checkout onepage success page.

Actual behavior:

No data in GA (Conversions -> Ecommerce -> Sales Performance).

Steps to reproduce:

Create a new order.

Preconditions

Seems like the data structure is not correct or GTM should be configured in a specific way. But there is no information about this in documentation.

Cay say that this example from google docs is working, if put it right after pushData:

dataLayer.push({
  'ecommerce': {
    'purchase': {
      'actionField': {
        'id': 'T12345',                         // Transaction ID. Required for purchases and refunds.
        'affiliation': 'Online Store',
        'revenue': '35.43',                     // Total transaction value (incl. tax and shipping)
        'tax':'4.90',
        'shipping': '5.99',
        'coupon': 'SUMMER_SALE'
      },
      'products': [{                            // List of productFieldObjects.
        'name': 'Triblend Android T-Shirt',     // Name or ID is required.
        'id': '12345',
        'price': '15.25',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Gray',
        'quantity': 1,
        'coupon': ''                            // Optional fields may be omitted or set to empty string.
       },
       {
        'name': 'Donut Friday Scented T-Shirt',
        'id': '67890',
        'price': '33.75',
        'brand': 'Google',
        'category': 'Apparel',
        'variant': 'Black',
        'quantity': 1
       }]
    }
  }
});

@srenon Got it. Just wondering for what the basic version has order data than?

Enhanced Ecommerce has a lot more features and there is no advantage in using that code. My recommendation is to either upgrade to Enhanced Ecommerce or disable that feature in GA

See https://support.google.com/analytics/answer/1037249?hl=en

image

@srenon So, to use enhanced ER Enhanced Ecommerce is required.

But in code the basic version generates something like this which seems enough for tracking orders:

  {
    "event": "gtm.orderComplete",
    "transactionId": "500011364",
    "transactionAffiliation": "Superior Seating",
    "transactionTotal": 69.95,
    "transactionSubTotal": 69.95,
    "transactionShipping": 0,
    "transactionTax": 0,
    "transactionCouponCode": "",
    "transactionDiscount": 0,
    "transactionProducts": [
      {
        "sku": "325-BUR",
        "name": "Fully Upholstered Black Wood Bennett Restaurant Chair with Burgundy Vinyl",
        "price": 69.95,
        "quantity": 1
      }
    ],
    "order": {
      "order_id": "500011364",
      "store_name": "Superior Seating",
      "total": 69.95,
      "subtotal": 69.95,
      "shipping": 0,
      "tax": 0,
      "coupon_code": "",
      "coupon_name": "",
      "discount": 0,
      "payment_method": {
        "title": "Pay By Phone",
        "code": "checkmo"
      },
      "shipping_method": {
        "title": "Free Shipping - Free",
        "code": "freeshipping_freeshipping"
      },
      "is_virtual": false,
      "is_guest_checkout": false,
      "items": [
        {
          "sku": "325-BUR",
          "id": "325-BUR",
          "parent_sku": "325-BUR",
          "name": "Fully Upholstered Black Wood Bennett Restaurant Chair with Burgundy Vinyl",
          "parent_name": "Fully Upholstered Black Wood Bennett Restaurant Chair with Burgundy Vinyl",
          "price": 69.95,
          "price_incl_tax": 69.95,
          "quantity": 1,
          "subtotal": 69.95,
          "product_type": "simple",
          "product_id": "2780",
          "discount_amount": 0,
          "discount_percent": 0,
          "tax_amount": 0,
          "is_virtual": false
        }
      ]
    }
  },
  {
    "event": "purchase"
  }

Basically, we use magento built-in GA module with tracking orders, and want to switch to GTM. All orders should be passed the same as it goes now via magento GA module. Is it possible with your module?

@mykhailo-superiorseating ... that code snippet is very similar to our enhanced e-commerce extension. You can easily customize it using our API to add any missing fields

Order
Trigger: event equals purchase (Google Analytics)

transactionId
transactionAffiliation
transactionTotal
transactionShipping
transactionTax
transactionCouponCode
transactionDiscount
transactionSubTotal
transactionProducts[].sku
transactionProducts[].parent_sku
transactionProducts[].product_type
transactionProducts[].name
transactionProducts[].price
transactionProducts[].quantity
Additional Order Date (Generic)

order.order_id
order.store_name
order.total
order.subtotal
order.shipping
order.tax
order.coupon_code
order.coupon_name
order.discount
order.payment_method.title
order.payment_method.code
order.shipping_method.title
order.shipping_method.code
order.is_virtual
order.is_guest_checkout
order.email_sha1**
order.email**
order.customer_id**
order.has_previous_order**
order.is_first_order**
order.previous_order_count**
order.is_new_customer**
order.items[].sku
order.items[].id
order.items[].parent_sku
order.items[].product_id
order.items[].name
order.items[].parent_name
order.items[].price
order.items[].price_incl_tax
order.items[].quantity
order.items[].subtotal
order.items[].product_type
order.items[].discount_amount
order.items[].discount_percent
order.items[].tax_amount
order.items[].is_virtual
order.items[].variant
order.items[].categories