Which is the best method to set up event tracking for new account signup steps in GA4? - google-analytics

Currently I'm using the following analytics.js method to track different funnels/goals and these get triggered on each specific page.
ga('send', 'pageview', '/ConversionEvents/Step1_MembershipPlan');
ga('send', 'pageview', '/ConversionEvents/Step2_AccountInformation');
ga('send', 'pageview', '/ConversionEvents/Step3_PaymentInformation');
ga('send', 'pageview', '/ConversionEvents/Step4_AccountConfirmation');
ga('send', 'pageview', '/ConversionEvents/Step5_ThankYou');
However, now that I switched to gtag.js I'm seeing what the best method would be to set these up. I came up with the following 3 options.
Option 1:
gtag('event', 'sign_up', {'step_name': 'step1_membership_plan'});
Option 2:
gtag('event', 'pageview', {'step_name': 'step1_membership_plan'});
Option 3:
gtag('event', 'step1_membership_plan');
I'm leaning towards using option 3 because it would be easier to view these events in GA4 since it will be listed as a different event name and it would be easier to create funnels.
From reading online, they say it's better to use the recommended/automatic events like sign_up and pageview for this but I'm not sure if then I can set up events to track the different parameters (e.g. step_name) that I set up for each step.
Which option would be the best to go with?
Thank you!

Personally, I would not clutter my GA4 with too many distinct event names.
But that's a matter of taste: If I understand Google's limits page correctly, web properties do not currently have a limit on distinctly named events, whereas app properties are limited to 500.
Ref.: https://support.google.com/analytics/answer/9267744?hl=en)
Instead, I would send the following events:
sign_up, when a user has completed the registration, aka visits the thank you page.
sign_up_step_complete, when a user has completed a step in the registration process. Sending the custom dimension step_name for each step.
(That is assuming that each step is just a virtual page view and does not actually send a page_view event to Google. If it does send a page_view, you can create the sign_up_step_complete event server-side based on the URL or not create an event at all and just use the page_view.)
This way, you're using the dafault sign_up event which might show up in a default GA report while also tracking intermediate steps in a separate custom event.
Finally, I would visualize the data in a free-form exploration funnel analysis.

Related

Google analytics api Get the userID / ClientID

I want to get the usage data of my customer out of google analytics, to make some usability analysis with it. For this, I need something that I can determine, which event was done by which user. Is there a possibility in a google analytics api to get this two parts linked?
You could add a user ID as a custom dimension, you'd probably want to set the scope to user.
https://support.google.com/analytics/answer/2709828?hl=en
This would allow you to connect up which users performed which actions.
Of course you can! :) I have used it in a lot of projects.
https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits
Example:
ga('send', {
hitType: 'event',
eventCategory: 'Video',
eventAction: 'play',
eventLabel: 'cats.mp4'
});
Since clientId has been made available through the API as ga:clientId you can use this value.
I would recommend using a custom User Id though - setting you own generated User Id in the script using the Universal Analytics User ID feature and in your backend db.
Also add the id to any link you send to your clients via email/sms/etc. that lands on your homepage to follow up on marketing performance.
You would need to have some javascript that grab the id and set it on the pageview. (like Linker, but adjusted for user id)
Note to anyone using the Universal Analytics User ID feature The values returned in ga:clientId is actually the userId Even more interessting. (As of time of writing) GA fails if you request clientId from a User ID view. So you should use a non-User ID view to get the User ID. :)

Two Google Analytics Codes - both not collecting correctly

I have inherited a site which has two GA-UA codes.
These are setup like this
// first code
ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('send', 'pageview');
//second code
ga('create', 'UA-XXXXXXXX-1', {'name':'second'});
ga('second.send', 'pageview');
I have no idea why they are setup like this and indeed do not understand the syntax of the second tracking code
The following can be observed
THE FIRST CODE
Custom events working and being successfully collected
Linked successfully to Adwords
Only has a few months of data and therefore we don't want to use this
THE SECOND CODE
Does not record custom events
Can't link to Adwords
Has years of data attached to it that we want to use
The plan is to just use the second code
For complete brevity custom events are being triggered like this
ga('send', 'event', 'Contact', 'contact-form', 'Goals');
My questions is this
"Because it has lots of historical data we wish to use code two but it is not collecting custom events. How do I get the second code to collect custom events so we can retire the first code? "
If you use two trackers on one site you need to give a name to at least one of them, else the first tracker is overwritten when the second one is initialized.
Thus the syntax for your second piece of tracking code - when the tracker is initialized it is assigned a name, in your example "second".
If you want to send data to that tracker you need to prepend the assigned tracker name to the send call, in your example:
ga('second.send', 'event', 'Contact', 'contact-form', 'Goals');
That is why the second tracker does not receive your event tracking calls, they are only being sent to the first "unnamed" tracker (actually if a tracker name is not assigned it defaults to t0).
Also do not think you can link an Adwords account to two different Google Analytics accounts, so. you'd need to unlink the first account and then link the second one.

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.

What is the correct syntax to set a custom dimension in Google Analytics?

I'd like to send some custom dimensions back to GA with every blog post that is read on my website - author and category.
When I set up the custom dimensions in GA I got this code to use:
var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension2', dimensionValue);
However, in the GA docs it specifies a different syntax using "send" rather than "set".
https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
ga('send', 'pageview', { 'dimension4': '<?=$categories?>'});
We are using universal google analytics, but this conflicting information means I'm not sure which syntax to use.
Thanks in advance
The first code block is how you set the custom dimension (CD) that can be sent with any hit: event, pageview, transaction, etc.
The second code block is how you set the CD and send it with a pageview. So it's a specific example of the first method.
Both are valid, it's just that the second example is more complete.
When sending data to CDs, don't forget to create and define them in the GA configuration as well.

Detect if user is already logged into LinkedIn and log the results

I'd like to track how many people hit my website that might be logged into LinkedIn. Depending on the results, I might add an interactive LinkedIn section using their API.
I already have the Javascript logic to detect if they're logged in. My question is what is the best approach to log this result? Can Google Analytics do it with a custom variable or event detection?
I'd love to report on something like, "10,000 visits to my website, of which X number of visitors were logged into LinkedIn".
Any help would be appreciated!
I believe Google Analytics Custom Tracking Variables would do the trick. Something along the lines of:
_gaq.push(['_setCustomVar',
1, // variable slot
'LinkedInUser', // variable
'true', // value
1 // variable scope, 1=visitor
]);
_gaq.push(['_trackPageview']);
For custom variables (not that is this is a user-triggered event after the initial GA page load logic, a call to _trackPageview is needed to push the data back to GA), or:
_gaq.push(['_trackEvent',
'PageView',
'LinkedIn'
]);
For custom events. Just pop something similar to that into your JS routine that checks for authed LinkedIn users.

Resources