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).
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.
We have a site where users login to access technical information. Before accessing the information, they also have to enter a set of filter options. Different filter options result in different information displayed on different pages but the url is the same.
For example, a user will get the following URL when accessing a specific document, regardless of what filter options set:
www.site.com/fr/category/document/
Depending on the filter options, different sections of the document will be visible.
Currently, no information in GA tells us what filters were used when visiting the page. We do not want to add filter parameters to the URL. At least not for the visitor, but maybe add it in the tracking somehow?
What would be the optimal/correct way to track that kind of information?
Best solution may depends how your site works etc. But how about using custom dimensions assigned to "hit" (pageview) scope? Maybe they will help in your case? Documentation: https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets (code in documentation depends how your GA is implemented of course). Thanks to them you can send with pageviews hit additional (custom) information (e.g which filters were used).
Other way could be just sending google analytics event (https://developers.google.com/analytics/devguides/collection/analyticsjs/events) with information which filters were used before pageview hit. Then just in Google Analytics panel you can create custom segment with sequence where 2 events occurred:
Click (or use filters) - event
See specific URL - pageview
Or of course you can implement both solutions (custom dimensions for pageview and events).
If I programmatically trigger a goal, event, or a ecommerce transaction on a certain page, does Google Analytics register a page view on the page? (which would show up under Behavior > All Pages for example)
With goals it's actually the other way round - a pageview might be defined as a destinantion goal, i.e. the pageview triggers the goal. However the goal is not a pageview by itself, especially since it only exists in the view configuration.
Events and transaction won't show up as pageviews, either - but then thinking in pageviews does not always make sense. It's much better to think of "interactions", people doing something with your page. So an event will not show up in the page content section of your report, but it is still an interaction that shows up in the behaviour/events report and may e.g. have influence on your bouncerate. PLus any interaction will count towards your hit quota (free version of GA is limited to 10mio user interactions per month).
Google Analytics will only trigger a pageview in the following two conditions:
A page view is registered whenever one of the pages on a traditional web site is visited. In other words, if a user takes an action that causes the browser to refresh, a pageview will be counted. Take note, this does not count for single-page (ajax) applications.
Additionally, a page view can be manually triggered by issuing ga('send', 'pageview'); using analytics.js. You can attach this code to nearly any sort of event (including ecommerce transactions).
A pageview will not be registered otherwise.
Read about analyics.js here.
Can anyone please help me clarify below queries?
Including GA code two times in a same page cause double visitor counts?
Using below/event code directly on the page, does it creates an events directly in the GA portal? Or first do we have to create 'Video' as event first in the GA portal and then call this so that it will map itself?
Ex: _gaq.push(['_trackEvent', 'Videos', 'Play', 'Gone With the Wind']);
In google chrome extensions, while publishing it will asks for the GA id, and we provide, and if we keep main GA code in the extension pages(popup.html) too, then does it count as twice?
1. Including GA code two times in a same page cause double visitor counts?
If it's the same code pointing to the same account# and you aren't doing anything inbetween like deleting cookies, then no, it will not cause double visitor count. However, it will cause double page view count.
Using below/event code directly on the page, does it creates an events directly in the GA portal? Or first do we have to create 'Video' as event first in the GA portal and then call this so that it will map itself? Ex: _gaq.push(['_trackEvent', 'Videos', 'Play', 'Gone With the Wind']);
Traditional GA does not require you to do anything special in the interface for this. You should see "Video" show up as a value in the Category dimension automatically.
In google chrome extensions, while publishing it will asks for the GA id, and we provide, and if we keep main GA code in the extension pages(popup.html) too, then does it count as twice?
I think you may be confusing your Google Developer Account ID with the Account# associated with your google analytics account, but if your extension outputs GA code and there is also GA code on the page and it points to the same account, then yes, it will count some things twice (see your first question).
To be clear, every time a _trackPageview is invoked, a page view will be tracked. So if you have multiple calls to that then it will count multiple times. If the visitor cookie isn't reset or broken, it will count as the same visit(or).
This seems like it should be a rather important use case for GA events but I really couldn't find any instruction on the net.
I'd like to create an event for any new registrations on my Wordpress site. If I can append that to logins as well, even better but the former is more important.
I also use WooCommerce so I'd need to ensure registration through that code path is included as well.
I'm familiar enough with adding the GA event code, I'm just not sure where to place it in this instance. I feel as if this functionality should be baked into the platform or most plugins. Maybe it is.
I noticed the 'Google Analytics for Wordpress' plugin has a checkbox for adding tracking code to registration pages however I'm not sure what exactly that does on the GA side? Does it create events? Is this whole question therefore pointless?
Any help here is appreciated.
I noticed the 'Google Analytics for Wordpress' plugin has a checkbox for adding tracking code to registration pages however I'm not sure what exactly that does on the GA side? Does it create events? Is this whole question therefore pointless?
From what I remember, by checking that box you create a custom variable for Logged In Status. By creating a custom variable, you can then create segments off of that and look to see how logged in users use the site compared to non-logged in users.
However, if you simply want to track new registrations, you could add GA event tracking to the submit button when the user submits the registration form.
If I were you, I'd do both.
If there is a page they land on after registering then just register that page as a goal in GA. I get your intent behind registering it as an event, but it might be easier to just do it as a goal.