Reputation: 101
I have software built with the .NET framework which is written in C#. I previously use Universal Analytics to track all the actions the customers have performed in my software so that I know what features they use the most. But as UA is now retiring and I need to use GA4 instead. I have created a new instance of GA4 based on my original UA account. But it seems that simply replacing the tracking ID in my existing tracking code doesn't send the data to Google anymore.
I am using GoogleAnalyticsTracker/SimpleTracker with my existing UA. Just wondering has anyone implemented successfully equivalently to GA4 so far?
Here are my existing codes if that helps, which works for UA only.
private static void TrackRequest([NotNull] string description, [NotNull] string path)
{
var hostname = "hostname";
var userDetails = "userDetails";
var simpleTrackerEnvironment = new SimpleTrackerEnvironment(
Environment.OSVersion.Platform.ToString(),
Environment.OSVersion.Version?.ToString(),
Environment.OSVersion.VersionString
);
using (SimpleTracker tracker = new SimpleTracker("**UA-ID**", simpleTrackerEnvironment))
{
var customDimensions = new Dictionary<int, string>();
customDimensions.Add(key: 1, value: hostname);
customDimensions.Add(key: 2, value: userDetails);
tracker.TrackPageViewAsync(description, path, customDimensions).WaitAndUnwrapException();
}
}
Upvotes: 1
Views: 270