document.addEventListener("DOMContentLoaded", function() { $( document ).ajaxSuccess(function( event, xhr, settings ) { if ( settings.url == "/cart/add.js" ) { var _learnq = _learnq || []; _learnq.push(['track', 'Added to Cart', item]); } }); });