Lukáš Volprecht
WebDesing & Programming
volprecht@gmail.com
Tel: +420 608 438 458
$(document).on('click', '.prelink', function() { var event = $(this).attr('data-event'); var target = $(this).attr('href'); var blank = $(this).attr('target'); trackClick(event, target, blank); return false; }); function trackClick(event,target,blank) { gtag('event', event, { 'event_callback': function(){ console.info(event); /*if(blank=='_blank') { // openInNewTab(target); openUrl(target); } else { openUrl(target); }*/ } }); } function openUrl(url) { document.location = url; } function openInNewTab(href) { Object.assign(document.createElement('a'), { target: '_blank', href, }).click(); }