', beforeToggle: function(trigger, element, expanded) { if(expanded) { $('html, body').animate({scrollTop: $('.product-header').offset().top}, {duration: 100}); } } }); $( document ).ready(function() { const buybuttons = document.getElementsByClassName('product-control'); function clickListener(e) { ga('send', 'event', { eventCategory: 'Outbound Link', eventAction: 'click', eventLabel: e.currentTarget.href }); const xhr = new XMLHttpRequest(); const url = 'https://fontastix.ch/api/stats'; xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/json"); const data = { "target": e.currentTarget.href.toString(), "source": document.location.href.toString() } xhr.send(JSON.stringify(data)); } for (let i = 0; i < buybuttons.length; i++) { buybuttons[i].onclick = clickListener } });