Universal Analytics event migration to GTAG usage

47 Views Asked by At

Good morning, right now I'm trying to migrate a bunch of Universal Analytic website events to the including of gtag library.

I'm wondering which would be the correct approach for migrating the current universal analytics click event to be used with gtag library: onclick="ga('send', 'event', 'Video tutorial links (inside CMS)')"

I was reviewing the Google documentation but I'm not pretty sure about if the below code would be the solution:

gtag('event', 'HowTo', { 'event_categpory' : 'Video tutorial links (inside CMS)' })

Thanks in advance!

1

There are 1 best solutions below

0
GBS On

With UA:

ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

With GA4:

gtag('event', <eventAction>, {
    'event_category': <eventCategory>,
    'event_label': <eventLabel>,
    'value': <eventValue>
});

The order changes a little bit, also notice that fieldsObject is gone.

You should give your event (that before was only an eventCategory) also an eventAction to make sense with GA4.

gtag('event', 'videoEventName', { 'event_category' : 'Video tutorial links (inside CMS)' })