In Google Analytics v3 it was possible to send custom events right from the frontend of the application, like:
gtag('event', 'my_custom_search', {
'event_category': 'custom_text',
'event_label': 'custom_label',
'value': 'custom_value',
});
In GA4 it's still possible to send predefined events, like search for example:
gtag('event', 'search', {
search_term: '1234'
});
Now we want to send our custom events again. So I simply tried this:
gtag('event', 'my_custom_search', {
search_term: '1234'
});
Unfortunately the custom event doesn't show up in the realtime view. I found this article to create custom events in the backend: [GA4] Modify and create events via the user interface.
My questions are:
Is it still possible to send custom events "on the fly"?
Must we really create all events beforehand in the Google Tag Manager?
If the anser to the second question is yes, then this is a lot of extra work, because we have to define the events in the Google Tag Manager and also in our frontend.
Current state, you'll have to name/configure them in GA4. Be careful of the limits, as you can't delete them. So no, you can't name them on the fly.
For your example, you'll want to keep it to the default "view_search_results" event, but augment via additional parameters, "type=custom"
As for your GTM question. This depends on how complex your GTM setup is currently and how well your events fit into the GA4 default list of events. Again you'll want to review and fit your existing events into the default events where possible and add new ones only after you've done the full review.
Implementation-wise, you might be able to reduce the number of tags by using a lookup table for existing events to map them to GA4 event parameters.
Edit: also you're referencing "gtag" a lot, it is different from Google Tag Manager. If your current custom events implementation is done through gtag then the migration will be more manual.
The my_custom_search should be able to fire, however, you'll need to install gtag before running your custom code, which is to set up the measurement id with gtag. You can reference google's document at here.
Related
We are using a custom tracking code to track events in UA, which was fine until now, but as there is a deadline to move all the events in GA4, I have already integrated the GA4 to the website, but I couldn't see those events there. Following is an example of an event I use.
_gaq.push(['_trackEvent', 'EventCategory', 'EventAction', 'EventLabel']);
Homepage=Category , PretSmallBanJan2023Stars = Event name , Banner= Event label
e.g. - _gaq.push(['_trackEvent', 'HomePage', 'PretSmallBanJan2023Stars-CH', 'Banner']);
There are over 15k events like this that are on the current setup which I have to move before July, so if there is any way to keep the same setup and see data in GA4 it will be greatly appreciated.
Kind Regards
You have to consider that in GA4 there are no more Category, Action and Label.
Follow This Link to move to GA4. Remember that there have been some major differences, as an example look at this Comparing metrics: Google Analytics 4 vs Universal Analytics.
In order to define a Custom Event in GA4 follow GA4 Custom Events
In order to define custom events you can use two methods:
1 - GTAG
2- DataLayer
I believe it would be easier if you use the first one or gtag.js API to send info or events to Google Analytic API. However, it is subjected to change(so you might be obligated to change something or update something on and off when Google decides).
1 - GTAG
As it is described in this link Set Up an Event for Website Apps for GTAG,
Before you begin:
Create a Google Analytics 4 account and property Create a web data
stream for your website Place the Google tag on your website It also
assumes that you have the following:
Access to your website source code The Editor role to the Google
Analytics account
To send events to Google Analytics this API has one function called gtag(), and whenever you want to send an event to Google Analytics, you use the following syntax:
gtag('event', '<event_name>', {
<event_parameters>
});
Finally, if you need the same metrics Category, Action and Label I suggest you to create Custom Dimensions for these three. So if you have an old-defined table in your Database, it is not going to change the fields or create loads to the developers. The documentation for creating Custom Dimensions and Metrics is here. Remember that it takes 48 hours for GA4 API to recognise your custom dimensions. There are some limitations as well that you can read at the link above.
2- DataLayer
In this method, you need to work with GTM or Google Tag Manager, as well.
To read more, you can follow this link GTM.
I have Google Tag Manager account created,
And I have Google Analytics account created,
Inside my app I only have GTM included, and after some research, I managed to connect my Google Analytics acc with GTM to track page views.
Now, what I used to do before with just using GA, I was using some custom events inside my app,
So ga('send', 'event', 'Videos', 'play', 'Fall Campaign');
Now I tried to do the same after GTM is connected but I'm not getting any events inside my admin
I also tried doing dataLayer.push with same event arguments and event is still not showing up
Does anyone have an idea of what I'm missing to get custom events working?
Also, I don't want them to be defined inside GTM (that would mean that for every custom event I need to create a trigger if I get it right)
Is it possible to just publish them without any configuration inside GTM?
Thanks!
You have to create Analytics Tag (type event), Trigger and some dataLayer Variables, you can find the guidelines here: https://support.google.com/tagmanager/answer/7679219?hl=en
I had to integrate the GTM and track few data into a webpage and im facing some comprehsion issues. I dont think it's code wise, but i don't get where i'm supposed to see the data that im tracking.
i've successfully added the GTM code into my application and defined some data to be sent inside the dataLayer variable, after that i can go to the GTM admin panel and choose to Preview and Debug, so i can see the data i'm trying to track and everything seems allright. Therefore, i don't know what happens to them next. I don't know where i can see the data that i track, where they are stored. I've linked my GTM account to my GA account so i can see the traffic and other datas, but not the ones i've put inside my dataLayer object.
Anyone know what are the next steps ?
Here's some screenshots of my tag
Thanks
I think Simo Ohava - the GTM "god" - is explaining it quite well:
Datalayer Basics:
https://www.simoahava.com/analytics/data-layer/
Google Tag Manager & Datalayer:
https://www.simoahava.com/analytics/google-tag-manager-data-model/
As far as I understand you, all your questions (including basics and how to access via tag manager - and more) are pretty nice answered/explained there.
I've linked my GTM account to my GA account
What do you mean by this? Where did you "link" the data? GTM tracks data via the tags you define to fire for various interactions on the pages, including pageviews, events, and transactions (all known as "hits"). Each tag that fires in GTM has an associated Universal Analytics property ID that comes from your Google Analytics account. You must include this ID in all your tags. This is where you tell GTM tags to send your data and this is where in GA you will find the reports on your data.
Simply pushing data to the dataLayer does nothing unless
you're also pushing events to it and using those events to trigger tags to fire
You've defined GTM variables to grab the data being pushed in
Your tags are configure to pull that data into your reports
EDIT
To pull data into GTM from the dataLayer, you need to do the following:
Make sure your data is pushed in the following format:
datalayer.push({
'event': 'your event',
'page': 'custom/path/path',
'otherData': 'custom dimension1',
'otherData2': 'custom metric1'
})
Create a Data Layer variable, whose name can be anything, and whose value is the name of the dataLayer key.
Include the Data Layer variable's name in whatever tag you need the data to apply to. For example, if it's a custom dimension you need to associate to your pageview, then go into the Advanced Configuration of the tag and add the data into the Custom Dimension section (remember to configure your CD in GA, and to include the index). You can be associating any kind of data to the specific tag (eg. page path, page title, page name).
Test and then publish your tag!
I'm using Google Analytics Enhanced Ecommerce with the datalayer on my webshop. Any event (product impression, detail view, add to cart, etc.) is added to the datalayer.
I'm also using Google Tag Manager. Currently, I just have one tag with Enhanced Ecommerce enabled, and 'Use datalayer' enabled.
I do get most data into Google Analytics, but in the Product Performance report, data like cart/detail and purchase/detail is all 0%.
I feel like I am missing some events that need to be added to GTM, but I am not sure which ones, and I'm not able to find clear documentation.
Should the single GTM tag with EE enabled cover everything, or should I add custom events? If so, which ones, and are there any examples available?
When you push e-commerce data to the dataLayer, you need to/should push an event as well, eg.
dataLayer.push({
'event': 'ee add to cart',
// The rest of your ecom dataLayer info
})
so that you can use an event tag that fires on the ee add to cart event and is also configured to read in the standard EE dataLayer. You should always push an event with the associated dataLayer and create event tags (or use the existing pageview tag) to capture that data. You should be able to find more examples here
For Event Tracking, is it necessary to first add event categories, actions and labels in admin or these can be added in code (as documentation suggests)? If not necessary to add in admin, what's to stop someone from spamming analytics with useless categories/actions via Web Console or node.js?
There is no admin option to define acceptable event categories, actions and labels. This is all done at the code level via _trackEvent. Whatever you place in the event tracking call will show up in GA.
As you mention, visitors could fire event tracking code within the console. From my experience, this is not very common or much of an issue to worry about. You have the same issue with custom variables and even pageview tracking (firing a virtual pageview).
You can use profile filters in GA to target and manipulate event data (exclude, include, etc).