document.addEventListener("click", function(event){ var current = event.srcElement || event.currentTarget || event.target; if (current.id.match("buy_link")) { var productMatches = current.id.match(/([0-9]+)_buy_link/); if (productMatches) { inTarget.event("add-to-cart"); } } }); document.addEventListener("click", function(event){ var current = event.srcElement || event.currentTarget || event.target; if (current.href && current.href.match("action=delete")) { inTarget.event("del-from-cart"); } });