Note: Google Universal Analytics or UA will be discontinued by Google on 1st July 2023. For information on the new GA4 analytics platform that Google now provides and how cloudscribe integrates with it can be found on the new Google Analytics GA4 Integration page.
In cloudscribe Core we use the GoogleAnalyticsTagHelper, GoogleAnalyticsHelper, and GoogleAnalyticsApiService provided by the cloudscribe.Web.Common library to track basic things like page views and also to track user account events such as Login Submit, Login Success, Login Failure, Registration Submit, Registration Success, and Registration Failure. We also track whether the login or registration event used a social login service such as Facebook or Twitter, or Google or Microsoft or whether it was just a local account.
The implementation for tracking these account events was basically using the approach from this tutorial.
The tutorial linked above is a good source also to begin learning about custom dimensions and metrics in google analytics. Our implementation uses pretty much the same dimension and metrics indexes used in that article. If you don't already have custom dimensions and metrics established in your google analytics then you should also be able to use the same indexes, but if you do already have some custom dimensions and metrics configured then there is a good chance the index numbers we used would conflict with ones you are already using, so we made them configurable in case you need to change them to use different index numbers for login and registration events.
Setting Up Custom Dimensions and Metrics in Google Analytics
To get the most benefit out of the built in user account tracking, you need to setup the corresponding custom dimensions and metrics in your google analytics property settings. Notice the "Custom Dimensions" and "Custom Metrics" menu items in the screen shot below.
Setup your custom dimensions as shown in the following screen shot:
and setup your custom metrics as shown in this screen shot:
Overriding the Indexes for Dimensions and Metrics
If you do already have custom dimensions and metrics using the same indexes, you can customize the indexes used by cloudscribe Core. The configurable settings are all shown below with their default values. If using cloudscribe Core you can update them in appsettings.json to whatever values you want.
"LoginRegisterEventCategory": "Login and Registration",
"LoginSuccessEventAction": "Login Success",
"LoginFailEventAction": "Login Fail",
"LoginSubmitEventAction": "Login Submit",
"RegisterSuccessEventAction": "Register Success",
"RegisterFailEventAction": "Register Fail",
"RegisterSubmitEventAction": "Register Submit"
Even though you can't store user names or identifying information in google analytics, if you are capturing UserID, it is possible using a Chrome extension to associate a CSV file that has the UserID along with other information, so that you can view the actual users in your reports.
Now that you have setup custom dimensions and metrics for user account events, you can use those for setting goals in Google Analytics. There are lots of tutorials online to learn about setting goals in Google Analytics.
In Summary, cloudscribe Core has built in tracking of page views and account events such as login and registration. You can see the actual code we use for tracking account events here. You can also track other custom events in your own custom features using similar techniques. See the Easy Google Analytics article in the documentation for cloudscribe.Web.Common to learn more.