Reputation: 5073
I'm trying to figure out how to convert below code to Javascript. Is there a conversion tool online for simple conversions?
$('head script[async][src*="analytics"]').on('load', function() {
ga('send', 'event', 'checkout', 'complete');
});
Upvotes: 0
Views: 32
Reputation: 155
I don't know if there's a conversion tool, but there is http://youmightnotneedjquery.com which holds resources for many things one can do without jQuery, compared with the jQuery way.
In your case just replace $() with document.querySelector and .on('load', fn) with .onload = fn i.e:
document.querySelector('head script[async][src*="analytics"]').onload = function() {
ga('send', 'event', 'checkout', 'complete');
}
Let me know if it works!
Upvotes: 2