Tracking sign_up event as a Goal in Google Analytics - google-analytics

I wanted to create a Sign up goal in Google Analytics. Adding an event for signup is simple enough:
gtag('event', 'sign_up', { method: 'Direct' });
This successfully created events
However when I try to configure the goal as such:
Nothing happens, the Goal conversion is not counted for the events shown above.
I am trying to follow instructions from here https://developers.google.com/analytics/devguides/collection/gtagjs/events
However I found very little documentation on tracking events as goals.
How do I configure a goal based on the standard engagement events in Google Analytics?

Try to set only Action equal to sign_up without value in Category.

I figured this out. The "Use the Event value as the Goal Value for the conversion" is the problem. Because my event is not sending a value, GA assumes it has zero value and zero value goals are not counted as a conversion.
I fixed this by choosing No for the option and entering 2.5 as the value. Now anyone sending the event counts as a conversion worth $2.5.

Related

Trouble recreating Google Analytics (UA) events in GA4

I have a bunch of mp3s and an audio player on my site. In GA3 (UA) I had an event that fired every time I hit the play button on a specific track. The event name was jPlayer, the track in question is the variable 'mediaName', which is the name of the mp3 file which is derived when I click play. In my code, mediaName is a string that gets sent out to GA. i.e. mediaName might be 'mycooltrack.mp3', or 'anothergoodtrack.mp3'
ga ('send', 'event', 'jPlayer', mediaName);
After reading the GA4 docs, I guessed that I needed to make a custom dimension, called "Track" which took the User Property/Parameter: mediaName.
So the new code in my function looked like:
gtag('event', 'jPlayer', {
'Track': mediaName
});
But after several days this hasn't been working either.
I guess I don't really understand what dimensions are and how to send an event with an 'on-the-fly' name variable to GA4, like I've been doing with UA for years.
You need to first create the event in GA4 interface. https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#zippy=%2Cin-this-article%2Creserved-prefixes-and-event-names%2Cweb
It is under "Configure" on the left-hand side. Then go through the steps.
Your configuration will look something like this, if you really like the "jPlayer" event name, then just replace "audio_play" with "jPlayer"
The code you used is still relevant and can stay the same, I'd just write "track" in lowercase.

Firebase analytics duplicated event log

Now i'm trying to use firebase analytics for analyze user data.
To do so, I followed the documented guide from developer site. So now I can recognize the data what I added in my project.
However, I cannot understand some index.
First of all, I made an event which user clicked button.
Firebase.analytics.logEvent("goto_qrscan") {
param("qrscanFrom", this#WalletMainFragment.javaClass.simpleName)
}
so, I guess that total event count between 30 mins(1370) should be same as parameter value(141), but it doesn't.
I didn't put above code any other place in project.
why this happening? and how can I understand that data?
Thx in advance!

Firebase logging error on automatic events

I am logging some custom events on Firebase Analytics, but some errors keep getting logged for automatic events (such as screen_view) along with the custom events, whether I call them explicitly or not. When I log regular custom events (a button click, for example), I can see them on DebugView without any errors.
I have validated the rules for names (maximum of 36 chars for event key, maximum of 100 for value) as this answer from Chintan points and confimed that no event has reserved names.
I keep getting the error code 13 - which means Event name is reserved, according to the Analytics Error Codes.
Any ideas of what might be happening? Anybody facing the same issue?
Here's how the error is shown at DebugView:
Thanks in advance!
Edit:
Adding a piece of the log, as requested:
Can you check to see if you are using your event names prefixed as "firebase_", "google_" or "ga_"?
As per the official documentation **The "firebase_", "google_" and "ga_" prefixes are reserved and should not be used.**
According to the API docs for Analytics.Event, screen_view is a reserved event name and cannot be used for logging your own custom event.

Measuring Page Load Time of single-page app with GA

I'm using Google Analytics in an SPA. For any virtual page redirects (like an AJAX call to refresh the body of the page), I'm getting a page load time of 0ms. Is there a way to track how long that takes, just as if it was a full page refresh? I'm hoping to include how long it takes for the AJAX call and also the time to download and display images that are loaded as a result.
As you have found, Google Analytics will not provide page timings for SPA's. This includes if you increase the site speed sample rate to 100. This is because Google Analytics calculate the page timings using the Navigation Timing API.
For example, DOM loaded would be:
$(document).ready(console.log((Date.now() -
performance.timing.domComplete)/1000))
To over come this problem, you will need to use custom metrics. The solution has three steps.
1) Set up a custom metric in GA.
Go to Admin > Property > Custom Definitions > Custom Metric.
Create a new Custom Metric, with the scope of Hit and the formatting type of time. Note: Specify time in seconds, but it appears as hh:mm:ss in your reports.
2) Set up a timer.
You will need to capture the time when you want to start the measurement of page load time.
An example solution to this might be by decorating all of your internal links, e.g:
$('a[href*="stackoverflow"]').click(function(){
time1 = Date.now()
})
3) Send the time eclipsed (in sec) to Google Analytics on the virtual pageview event.
When the virtual pageview event occurs (which triggers your virtual pageviews), retrieve the difference between the current time (Date.now()) and the time which the timer was started (time1).
Using Google Tag Manager, a custom javascript variable can be created as below:
function(){
return (Date.now() - time1)/1000
}
This value then needs to be sent with the pageview, against the custom metric index set up in step1.
ga('send', 'pageview', {
'metricX': pageLoadSpeed
});
Using the custom metric along with calculated metrics (e.g. {{virtualPageTimings}}/{{pageViews}}, you will be able to calculate your average virtual page timings.
Bonus:
To make the measurement more accurate, set up a secondary custom metric to count the number of virtual pageviews. This will make sure that pageviews which users are directly navigating to are not taken into consideration.
To do this, create a custom metric with the scope hit and the formatting integer.
Then with every virtual pageview, send the value 1 against the custom metric index. E.g:
ga('send', 'pageview', {
'metricX': pageLoadSpeed,
'metricX': 1
});
This allows for the calculated metric:
{{virtualPageTimings}}/{{virtualPageViews}}
If you checkout the Google Analytics docs, you can find out about the siteSpeedSampleRate option, which basically allows you to turn on your site tracking beacons for a percentage of your users.
By default this value is at 1, but I'm assuming you might want to turn it to 100. It might affect a bit in term of network usage since it will have to transfer more data to GA, so take that into account depending on your users and how they access your website (through mobile, bad coverage in some countries...).
You'll have to modify your tracking code to integrate something like the following:
ga('create', 'UA-XXXX-Y', { siteSpeedSampleRate: 10 })
You can send the timing manually, As everything on Google Analytics. But it's a little bit tricky to do,if I'm honest I would no do it unleast it's necessary. All the data on the time report are based on a hit called timing, this hit is send after the pageView and contains the following information.
If you can see my example, I forced the tool to send the hit, just after the pageview goes another hit with a special list of parameters.
plt : Specifies the time it took for a page to load. The value is in milliseconds.
pdt : Specifies the time it took for the page to be downloaded. The value is in milliseconds.
dns : Specifies the time it took to do a DNS lookup.The value is in milliseconds.
rrt : Specifies the time it took for any redirects to happen. The value is in milliseconds.
srt : Specifies the time it took for the server to respond after the connect time. The value is in milliseconds.
tcp : Specifies the time it took for a TCP connection to be made. The value is in milliseconds.
dit : Used to send a random number in GET requests to ensure browsers and proxies don't cache hits. It should be sent as the final parameter of the request since we've seen some 3rd party internet filtering software add additional parameters to HTTP requests incorrectly. This value is not used in reporting.
clt : pecifies the time it took for the DOMContentLoaded Event to fire. The value is in milliseconds.
More info of this parameters on : https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters and
You can see more info of this hit on
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings
So what happens now?, if I launch another pageview in this SPA, the second pageview on the same page will not carry this hit and you will ever get 0 of loadtime. You can use the command as the official documentation but if you use it you will notice that is not the same hit (i have to double check that). Other option is send it manually using the command 'send' and attaching the desire information. Check your pageview hit structure to be sure that your timming is actually attaching to your previous hit.
The comand to send the timming after the pageview is send will be something like that, use the &dl parameter or 'dp' parameter to attach the timming to the ajax page.
ga('send', {
hitType: 'timing',
'&plt': 1,
'&pdt': 1,
'&dns': 1,
'&rrt': 1,
'&srt': 1,
'&dit': 1,
'&clt': 1,
'&dl': 'http://cl.edreams.com/',
});
Now all the values '1' needs to be updated for the correct one, now how to determine the time of each parameter not sure at all. Also remember that the sampling by default is only for the 1% of the sessions, send this hit only in a few cases.
Disclaimer : This is a very experimental implementation, we are forcing the Js to send unexpected information. Test it well before to pass it to a final project
Greetings

Trigger analytics event in the past with a specified date

I'm capturing the date of a product installation when user extends a trial, and pass it to a thank you page as a parameter. Then I capture it and want to retroactively trigger event in the past.
From docs the code looks like:
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
And nothing is said about ability to set any dates.
Is there a way to do it?
You can not push any events retroactively in Google Analytics.
All data is connected to the time that they were sent on.

Resources