October 2017
Intermediate to advanced
370 pages
8h 57m
English
We can use a similar setup too when items are removed from the cart. This time, we need to target the remove-from-cart link. First, the trigger: the remove link has the CSS class cart-del, so we can use this to target the link:
"triggers": { ... "remove from cart": { "on": "click", "selector": ".cart-del", "request": "event", "vars": { "eventCategory": "Cart", "eventAction": "Product removed" } }}
And now we add the data attribute that will populate the eventLabel variable to the delete link to pass the product ID to the analytics request:
<div class="cart-del" ... data-vars-event-label="{{product_id}}">X</div>
Read now
Unlock full access