How to check whether the product was shortlisted before adding to cart? (Google Analytics Enhanced Ecommerce)

Business Objective: It will answer your business question of how many people move product from shortlist to cart and after how many days.

I still remember a client who was looking for the below output which is quite interesting and useful in an e-commerce business.

Add to Shortlist: Currently, we get an “add to cart” in an enhanced e-commerce section of the Google Analytics, in order to get an “add to shortlist” we will need to pass a custom metric with product scope. Please note that this approach is session independent means even if the session is over we can come and move product from shortlist to cart and desired result will get achieved.

Implementation steps:
On click of an “Add to Cart” check whether same product is present in add to shortlist or not if present then sends metric value as 1 else 0.

Sample code:

// Measure adding a product to a shopping cart by using an ‘add’ actionFieldObject
// and a list of productFieldObjects.