Incomplete Purchase journey and Checkout journey

Created on 6 November 2023, almost 2 years ago

I would like to measure Drupal Commerce purchases and journeys.
Yesterday I've successful installed the module (Google Tag 2.0.2 on Drupal 9.5.11, Commerce 8.x-2.36) and made a test purchase.
On the /admin/config/services/google-tag page all events are enabled included: Add payment info, Purchase (Commerce), Add shipping info, Begin checkout, Add to cart.

Today I can see in Google Analytics (GA4) in the Ecommerce purchases:
- Items viewed: 4 (OK)
- Items added to chart: 1 (OK)
- Items purchased: 1 (OK)
- Item revenue: 1,52 usd (OK)

But on the Purchase journey and checkout journey tabs things are not so bright:

Purchase journey:
Step 3 - add to cart
Step 4 - begin checkout
Step 5 - Purchase
These steps all show zero values. The most interesting is that the "Step 5 - purchase" show zero because as I mentioned on the "Ecommerce purchases" tab I've seen a purchased item.
So as I understand my setup measures events related to a product but not measures the events related to the shopping in a broader sense.

Checkout journey:
Similar problems as we seen on Purchase journey tab. These steps show zero:
Step 2 - add shipping
Step 3 - add payment
Step 4 - purchase

Could you please provide some hint where should I look for the solution?
Should the module measure (send events to GA) these events related to checkout and purchase journey with the appropriate module settings or are these events not implemented yet? Need more setting customizations?

Screenshoots attached.

Thank you

πŸ’¬ Support request
Status

Active

Version

2.0

Component

Documentation

Created by

πŸ‡­πŸ‡ΊHungary kepesv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @kepesv
  • πŸ‡ΊπŸ‡ΈUnited States g.paluch

    It's likely not a module issue. If you can confirm that your dataLayer sends data in the console, it is likely a GA threshold, meaning your site doesn't produce enough data for GA. You can change this in GA in Settings>Data Collection and Modification>Data Collection by disabling
    "Include Google signals in reporting identity."

  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States g.paluch
  • πŸ‡­πŸ‡ΊHungary kepesv

    Many thanks for Your response.
    Google signals data collection wasn't activated yet (so there was no "Include Google signals in reporting identity" switch).
    Now I've turned on Google signals data collection. I'll check it a few days later.

  • Status changed to Active almost 2 years ago
  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    Add payment info and shipping are currently empty placeholders that are not implemented, so it's not surprising that nothing shows up there.

    I'll likely have a look at that soon as we probably need this too.

  • Assigned to durifal
  • πŸ‡ΈπŸ‡°Slovakia durifal

    I am working on the patch to support data for payment and shipping info.

  • Issue was unassigned.
  • πŸ‡ΈπŸ‡°Slovakia durifal

    I have just found out that the checkout process on the project is too custom to create universal patch :-(

  • πŸ‡ΊπŸ‡ΈUnited States rszrama

    (I'm marking this and another issue with a "Deprecate Commerce GTM" tag. These are issues that fill gaps for us to formally recommend closing that module and migrating sites to this one.)

  • πŸ‡ΊπŸ‡¦Ukraine khiminrm

    I've found two solutions how we can fix it. Iv'e tested only 'add_to_cart' event yet. But I think it should work other events too.

    So first solution is to use GTM tags by using these steps:

    GA4 Event Tag Setup:
    Ensure the GA4 Event tag in GTM for add_to_cart is correctly configured. This includes selecting "Google Analytics: GA4 Event" as the tag type, entering the correct GA4 Measurement ID, and setting the Event Name to add_to_cart.
    Ecommerce Data Source:
    Verify that "Send Ecommerce data" is checked within the tag settings and "Data Layer" is selected as the Data source under "More settings β†’ Ecommerce."
    Trigger Configuration:
    Confirm the trigger associated with the add_to_cart tag is correctly set up as a "Custom Event" with the Event Name matching add_to_cart.

    So in my test GTM I have added such tags:

    First one is config tag for GA4, where I've used ID from my GA:

    And another one is for the 'add_to_cart' event (it also uses the same GA ID):

    With such configuration I was able to see the 'add_to_cart' event in Google Tag Manager Preview Mode and in DebugView in GA4.
    But there were two sent events and one of them had 'send_to' parameter with GA ID and another one didn't have those param:

    And in the first event we have value under 'Hits Sent'.

    Then I've tried to pause the 'add_to_cart' event tag in my GTM's tags settings and the param with hardcoded GA ID directly into the code of the AddToCartEvent::getDat():

        return [
          'currency' => $unit_price->getCurrencyCode(),
          'value' => $this->formatPriceNumber($adjusted_price),
          'items' => [
            $item_data,
          ],
          'send_to' => 'G-MYGA4ID',
        ];

    With this fix I had only one add_to_cart event and it was visible in DebugView in GA4. I hope it will be displayed on Purchase Journey page too. Will need to wait when the data will be updated there.

    I've also noticed caching issue when tested the event. So maybe it's related to https://www.drupal.org/project/google_tag/issues/3281487 πŸ’¬ GTM not firing when page is cached Active
    So I've just disabled caching in my settings.local.php file:

    <?php
    
    ///**
    // * Enable local development services.
    // */
    $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
    
    $settings['cache']['bins']['render'] = 'cache.backend.null';
    $settings['cache']['bins']['page'] = 'cache.backend.null';
    $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
    

    For the second solution with the 'send_to' param we need to improve code of the google_tag module to be able to add GA ID and use it in return data for each event. Not sure or we need one global setting field for GA ID and checkbox for an events to include those 'send_to' param or it would be better to add the field per each event and use it when it's needed?

  • πŸ‡ΊπŸ‡¦Ukraine khiminrm

    Committed code to send data for the add_payment_info. Not sure if it's correct to use the payment insert event. Maybe we should try to trigger the event on the payment information checkout step submission. And maybe similar should be for the add_shipping_info event...

Production build 0.71.5 2024