screen_name restrictions for Google Analytics App+Web property - google-analytics

We are using Google's "App+Web" property tracking for our mobile & web apps. For event names, there are restrictions:
Event names can be up to 40 characters long, may only contain alphanumeric characters and underscores ("_"), and must start with an alphabetic character.
So all our event names are like content_play_click or view_privacy_policy etc., for example:
gtag('event', 'view_privacy_policy', data || {});
But is there any similar restriction on screen_name for screen_view using gtag?
For example:
gtag('event', 'screen_view', {
'screen_name': 'Home Page'
});
Because it's not showing properly in Google Analytics. It's showing (other) or (not set):
I tried to search a lot about this but couldn't find anything solid. Any idea?

you need to set app name in gtag event:
gtag('event', 'screen_view', {
'screen_name': 'Home Page'
'app_name': 'Your app name'
});

Related

setting up user_id for Google Analytics

I followed the directions given when setting up the User-ID option.
I then created a view named 'user_id' for showing user_id info, but I am not seeing anything. When enabling User-ID, the code said to add the following to my tracking code.
gtag('set', {'user_id': '12345UserIdHere'});
However, when I go to the 'user_id' view, nothing is shown.
My current goal is to view which user ids were browsing the system during a given period of time.
Edit:
I am using this library:
https://www.googletagmanager.com/gtag/js?id=MY-ID-STUFF
I mostly used GTM, so I am not completely familiar with the gtag.js syntax, but I don't believe it has a "set" method. According to the documentation you'd have to set the user id in the "config" call instead:
gtag('config', 'GA_MEASUREMENT_ID', {
'user_id': 'USER_ID'
});
(Things in caps are placeholders).

Google Analytics Global Site Tag Custom Parameters

According to Google's gtag.js guide, it seems like we're able to define custom parameters. However, when using the code examples, only the Event Action gets populated. The Event Label is recorded in Google Analytics as "(not set)" and the Event Category as "general".
Code Example from developers.google.com:
gtag('event', 'video_play', {
'video_title': 'My promotional video',
'duration': '01:32'
});
It's also interesting to note that I cannot figure out how to show custom parameters as the columns in Google Analytics seem to be statically set to "Event Category", "Event Action", and "Event Label". These correspond to the default keys of "event_category", "event_action", and "event_label". Using these keys sends the values correctly. The following code works:
gtag('event', 'redirect', {
'event_category': 'Announcements',
'event_label': '/announcements/index.jsp',
Has anyone gotten custom parameters to work or is this a feature that hasn't been implemented yet in gtag.js? Is there additional configuration needed that I may have missed?
If you you were thinking of GA Custom Dimensions and Custom Metrics, yes it is available in the gtag.js / Global Site Tag syntax, see
https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
in the form of a Map of CD indexes and attribute explicit names, followed by setting values to explicit attribute names.
for example
// Maps 'dimension2' to 'age'.
gtag('config', 'GA_MEASUREMENT_ID', {
'custom_map': {'dimension2': 'age'}
});
// Sends an event that passes 'age' as a parameter.
gtag('event', 'age_dimension', {'age': 55});
See also https://developers.google.com/analytics/devguides/collection/gtagjs/migration#custom_dimensions_and_metrics
However, gtag.js is a wrapper to make analytics.js easier to implement by hiding some its complexity.
If you are used to analytics.js, keep using it, you get more control on its behavior.
Or move to GTM, it's way more flexible.

Capture the value of an HTML variable

I am trying to read the value of a variable in an HTML page, and report it to Google Analytics.
The line in question is this:
<h1 id="results-heading">Your search for <span class="query"></span> returned <span class="total-results"></span> result(s).</h1>
I want to capture the value of the "query" variable.
TIA!
retrieving the query value
Assuming you are using jQuery, you can get the text present inside the span.query using this:
var queryValue = $('span.query').text()
sending to Google analytics
Then you may send this information to Google Analytics using one of the supported mechanisms that is the most appropriate to your use case (which is not described in the question). Examples of how this may be done:
event
ga('send', {
hitType: 'event',
eventCategory: 'you-know',
eventAction: 'whatever',
eventLabel: queryValue
});
(cf. event tracking).
custom dimension
ga('set', 'dimension1', queryValue);
(cf custom dimensions and metrics).

Google Analytics: Event Tracking Parameters

I am using ga for my website.
but when i call track event like this
_gaq.push(['_trackEvent', 'abc', 'def','pqr','xyz']);
it does not work but when i call function by removing last parameter i.e 'xyz' it works properly it looks like this
_gaq.push(['_trackEvent', 'abc', 'def','pqr']);
where _gaq is an array which contains my ga account no. and domain info.
my concern is I want to pass four parameter with '_trackEvent' parameter like this..
_gaq.push(['_trackEvent', category, action,label,value]);
but this is not working.
Plz help
The Google Analytics API Event Tracking Guide states that the trackEvent method accepts 5 parameters:
category (required)
action (required)
label (optional)
value (optional)
non-interactive boolean (optional)
The second-to-last parameter (value) has to be an integer, and so does not work when a string is passed.

Google Analytics: can I combine trackEvent and trackPageView into a single call?

I am combining Google Analytics' _trackEvent and _trackPageview into a single call, like the following:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20822178-2']);
_gaq.push(['_setCustomVar', 1, 'My Custom Page View Variable', 'My Value']);
_gaq.push(['_trackEvent', 'My Category', 'My Action']);
_gaq.push(['_trackPageview']);
[...GA snippet insertion...]
This generates two __utm.gif requests to Google. This would be okay except that the request with the _trackEvent information ALSO contains the CustomVar info, which leads me to believe that Google counts the pageview on BOTH requests. I don't want to double count my page requests... so is Google smart enough to throw away the pageview info sent with the _trackEvent call?
Thanks!
It won't double count page views but it is double counting your custom var. If you don't want that, reorder the pushes, make the trackpageview come first, then the custom var, then the event

Resources