Replies: 10 comments 1 reply
-
@DavidKuennen @idarek can I bug you guys as well in this. Above should work with the normal GA 4 script. Wouldn't it work out of the box with minimal as well? No auto tracking just tracking sent on click. Or is there something else that is missing in @jahilldev version? |
Beta Was this translation helpful? Give feedback.
-
Hey @wpsumo, Provided you've set <a href="https://website.com" onclick="track({ /*[...]*/ })">Click</a> Obviously providing the relevant options to It's also worth noting that this package automatically records generic anchor and button clicks for analysing how users are interacting with your site. If you look through your events you should see something like the following: Each Hope that helps 👍 |
Beta Was this translation helpful? Give feedback.
-
@jahilldev Many thanks very helpful.
Thanks but not even made the switch from universal, was sticking as long as I could! :D This would be too generic for the use case of these events, but thanks for sharing, all btn or hrefs have the same class for example. What we are coming from is that we track events like: Not exactly like below but get the idea So converting this to track would be something like this right? The new track confuse a bit, but just to get used and test it. But coming from Universal and the normal GA script to insert action and label and category directly as the value and not having a label for each event and then value.
|
Beta Was this translation helpful? Give feedback.
-
Hey @wpsumo, If you'd prefer to stick with the standard GA way of doing explicit tracking calls, I posted a compatibility function in another issue, see below: That way, you can continue using the standard G tag method but using the minimal script. If you're not using build tooling, or a node environment, you can swap the const GA_ID = 'G-XXXXXXXX';
window.gtag = (method, ...args) => {
if(method === 'config' && args[0] === GA_ID) {
window.track(GA_ID) // page_view
return;
}
/*[...]*/
} |
Beta Was this translation helpful? Give feedback.
-
@jahilldev Many thanks, just not following the way to keep using standard google tag methods for events tracking while using minimal script as. Am I understanding it like this and autotrack is needed if I run it locally? So also like this :
And then I can use:
Still recommended to use
|
Beta Was this translation helpful? Give feedback.
-
Hey @wpsumo, Yes, you'll need <script>
window.minimalAnalytics = {
trackingId: 'G-XXXXXXXXXX',
autoTrack: true,
defineGlobal: true,
};
</script> And yes, you'll still need to prefix all event details with either The second link I posted is from another user that shared his working solution, which handles the value type for you: It's worth noting that UA and GA4 handle events very differently; There is no There's a bit of a learning curve, so good luck! |
Beta Was this translation helpful? Give feedback.
-
@jahilldev Many thanks, I think it makes sense to stick to new |
Beta Was this translation helpful? Give feedback.
-
Great, sounds good. I'm going to close this issue for now, feel free to open another if you need to 👍 |
Beta Was this translation helpful? Give feedback.
-
So i read this conversation but still abit confused. This was my old script with ma.trackEvent, which is not working anymore. if (typeof gtag === "function") { I tried to change this old MA code to this: track({ type: 'Click', event: {'event_category': gaEvent} }); The "Click" works but the event does not sent the parameter. What am i doing wrong here? |
Beta Was this translation helpful? Give feedback.
-
@TykkiD @jahilldev Didn't play with the But I think it would be good with a few code examples in the readme for the You can continue using these old category and label an acitons just by using below I think.
But it's better to use the new track() and use custom meta with ep and epn. @jahilldev You understand it the best. Can you share a full code example of this? Is this correct?
|
Beta Was this translation helpful? Give feedback.
-
@jahilldev Bugging you here in a new thread instead.
I look for a html onclick action, so we dont have to run the javascript event listner globally when its not needed. We run it only when the user clicks on the action.
@jahilldev Any process on inline event tracking like the
onclick="ga('send', 'event', 'eventCategory', 'eventAction', 'eventLabel');"
Basically all I want is to do as you had in universal Event:
ma.trackEvent('Category', 'Action', 'Label', 'Value')
How would it look for example on a link element.
<a href="https://example.com/link/">Visit</a>
or am I seeing this wrong and this should work?
Beta Was this translation helpful? Give feedback.
All reactions