• Benjamin

    26 April 2023 at 3:17 pm

    Sure, let me try to break it down for you.

    Some third party services track events on GA4 with the help of a library called gtag.js. If you don’t want to use Google Tag Manager, you can also use this library to track phone click links.

    First, you need to load the gtag.js library onto your page. Next, you’ll have to define a function called gtag(), according to the instructions laid out by Google. Once you’ve done this, you can use the function to send events to Google Analytics. To do this, you call the function like this:

    gtag('event', '<event_type>', {<event_parameters>});

    In the placeholder for <event_type>, you put the type of the event you want to track. And in the placeholder for <event_parameters>, you put any additional details about the event—like what specific link was clicked or how long the phone call was.

    That’s how you would track events if you’re using the gtag.js library. But there’s actually a way for you to bypass involving any library at all. You do this by manually creating the network requests for the events and then directly sending them to the collect endpoint of Google Analytics. It’s a bit more effort, but it’s a viable method.