I’ve created a small Elm module that allows you to interface with Google gtag.js. Supports some default events, and supports custom events.
You can find it here.
As it uses ports, I can’t publish it, but it should be very easy to add to your project, full instructions provided.