View Cart Event in Google Analytics 4

To know how often your users look at their carts, you need to use the view_cart event in GA4. View_cart event is just like view_Item and add_to_cart events. It takes three parameters. 1. Items are an array containing the items in the shopping cart. 2. Value, which contains the total value of the items in the shopping cart. 3. Currency items is the only one that is required. However, passing in value and currency will provide more meaningful reports, and it is highly recommended to pass all these three parameters.

view_cart-event-parameters

If gtag is called on the webpages, the below image shows how the gtag call will look like. The event name is view_cart. It has currency, value, and items array. If Google Tag Manager is used, it needs the information about the items in the cart and a trigger to indicate that the user is viewing the cart.

gtag-code

As mentioned in the previous articles, it's a best practice to have the items' information in a data layer and then use a custom event as a trigger in the Google Tag Manager account of the Ecommerce Demo Shop (we use this website in all of our articles). Put the Google Tag Manager in preview mode and launch the eCommerce Demo Shop.

clicking-view_cart

 

Click on Connect. The site is loaded. Tag Assistant is disconnected. Go to Tag Assistant and click on continue. Go back to the site and add two items to the cart. Then click on view_cart.

after-clicking-view-cart

After clicking, it shows the two items. At this point, the developers have to create the data layer and the custom event. Go to Tag Assistant and see there is this custom event called view_cart. Clicking on it will show the data layer that's pushed. Expand and see view_cart is the name of the event. There is an eCommerce object with three values: currency value and items.

view_cart-data-layer

It has two items. The total value that's listed on it is the sum of the values of those two items. The first item value is 18, and the second item value is15. The sum is 33. If there are more items, it will be listed there, and the value will be the total.

eCommerce-view-cart-tag-configuration

We got our custom event and the values that we need. Now we can go back to Google Tag Manager and set this up in Google Tag Manager. Click on Tags, click on new, and call it an "eCommerce View Cart." Click in the middle, pick GA4 Event, then GA4 base Tag, and then event name is view_cart. That's the name of the event that Google Analytics 4 expects. It needs three parameters there.

custom-event-trigger

Currency, value, and items are the required three parameters, and the data layer variables are already pulling this information. We can reuse that dlv-currency, dlv-value, and dlv-items. Go ahead and save it. Click on add trigger and create a new trigger name as "CE View Cart" CE generally denotes the custom event. Click in the middle and then pick the custom event. The name of a custom event is what our developers had put in the data layer, so it's view_cart. Go ahead and save it and then save the tag. Finally, submit it. We are live once submitted. Go back to the site of the view_cart event again.

view-cart-event-in-GA4-real-time-report

Please refresh that page so that it triggers another event. Then go to Google analytics 4 and look at the real-time reports in Google Analytics real-time reports. Scroll down and can see the view_cart. Check for the latest event, which will show the last view_cart event. This view_cart event does not show up in any of the predefined reports. However, after 24 hours, it will appear in the event data in exploration.

Google Analytics 4 help and support

We are here to help you with all your Google Analytics needs. Our team can get you up and running in no time and also train you and your team to save you a lot of time so that you can focus on driving the business outcomes rather than configuring Google Analytics 4.

Online Course - If you want to learn on your own then check out Google Analytics 4 Masterclass

Workshop - We conduct the onsite customized workshop. Reach out to us for more details.

Consulting - Reach out to us for more details.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *