Complete guide how to setup GA4 on Shopify

Step 13. How to implement GA4 remove from cart event in Shopify

Published by
Oct 25, 2022

If you want to analyze the behavior of customers who have products in their cart, it makes sense to add the “remove_from_cart” event.

Below, you will find instructions on how to do it using Google Tag Manager and data layer variables in Shopify.

Implement data layer variables in Shopify.

Actually if you have implemented properly variables and you already have all needed data in data layer that have to be sent to GA4.

However you need to implement event variable to be able to create add_to_cart trigger. To do that you have to add to your "remove from cart" button additional java script code. You have to find in your Shopify admin > Online store > Themes code snippet responsible for presenting "remove from cart" HTML element. It can be included in additional section template like: "cart.liquid".

  1. When you find this HTML element you need to add in this following code to the onclick action:
  2. 
    dataLayer.push({
    'event': 'remove_from_cart', 
    'items': [{
               item_id: {{ item.variant.id }}, 
               price:{{ item.variant.price| money_without_currency }}, 
               quantity:{{ item.quantity }} 
             }]
    }); 
    
  3. Create trigger that we use to fire remove_from_cart tag. Go to trigger section and create new trigger:

    GTM new trigger.

    Create new “CE – remove_from_cart” trigger as follow:Remove from cart trigger.

  4. Create GA4 – remove_from_cart tag in Google Tag Manger. Go to "Tags" and click "New" button to add new tag. 

    ../media/art/15/GA4 – remove_from_cart tag in Google Tag Manger.jpg

    Name it "GA4 – remove_from_cart", then choose tag type and select "Google Analytics: GA4 Event", and your configuration tag that you have already created here: How to implement GA4 Configuration tag in Google Tag Manager? and set "Event Name" to "GA4 – remove_from_cart".
    Next step is to setup "Event Parameters" as follow:Setup Event Parameters.

    then choose your trigger that you have already created a while before (CE – remove_from_cart)choose trigger already created

    and click "Save" button on the top right corner, and click "Submit" to published.

Lets go now to the next step of our guide which How to implement GA4 login event on Shopify.

Published Oct 25, 2022 by Anna Bacciarelli

Information About the Authors

Anna Bacciarelli

During twelve years of professional work, I have gained experience in various positions in many fields. The variety of classes and professional experience taught me openness, independence, creativity, a positive approach to people and teamwork.Currently, I would like to focus on a new, extremely interesting path that is IT, and more specifically internet analytics. From the beginning of 2022, I have been gaining experience using the following tools: Google Analytics, Google Tag Manager and Google Data Studio.


If you enjoyed the article please share it:

Other articles about Shopify
Complete guide how to setup GA4 on Shopify.

This guide is all about how to implement Google Analytics(GA4) on Shopify. To setup GA4 on Shopify website we use Google Tag Manger(GTM) and Shopify data layer.

Oct 12, 2022
1. How to create Google Analytics account for Shopify website

If you want to measure traffic on your Shopify website, the first thing is to create Google Analytics account for your website

Published by Piotr Ulacha
Oct 13, 2022
2. How to create Google Analytics (GA4) property for Shopify website

If you have Google Account but you don't have GA4 property yet, because for example you are still using Universal Analytics property (former version of GA4) you have to create new GA4 property.

Published by Piotr Ulacha
Oct 14, 2022
3. How to create Google Tag Manager account for Shopify website

Because we will use Google Tag Manger as a method to implement Google Analytics 4 you have to create GTM account.

Published by Piotr Ulacha
Oct 15, 2022

4. Recommended GA4 property settings for Shopify

If you want to get the best out of Google Analytics 4 apply the following recommended GA4 settings and best practices.

Published by Piotr Ulacha
Oct 16, 2022