dotnet / windows-sdk-for-google-analytics

SDK to connect to Google Analytics from Windows Store (UWP) Apps, Windows desktop apps written with .NET, and Xamarin Apps
MIT License
102 stars 33 forks source link

PageView instead of ScreenView #36

Open robintschroeder opened 6 years ago

robintschroeder commented 6 years ago

In trying to use this library when building a WPF Visual Studio extension, I used the Managed Core code and wrote my own PlatformInfoProvider, etc. I noticed that the call was being made for a ScreenView much like Google Analytics is requesting a PageView. I don't know if I had another setting wrong, but basically, the ScreenView wasn't registering in GA, but it was coming up as some sort of an anonymous hit? Not sure exactly. Once I added this method to the HitBuilder.cs, and used it instead of the HitBuilder.CreateScreenView, it worked just fine.

 private const string HitType_Pageview = "pageview";

 public static HitBuilder CreatePageView(string pageName = null, string title = null)
        {
            var data = new Dictionary<string, string>();
            data.Add("t", HitType_Pageview);
            if (pageName != null) data.Add("dp", pageName);
            if (title != null) data.Add("dt", title);
            return new HitBuilder(data);
        }
LindaLawton commented 6 years ago

There are two different types of Google Analytics accounts. Web accounts which work around pageview hits and mobile accounts which work around screenview hits.

If you are sending page views to a mobile account the data will not show up in the website the hits just get droped you must send the correct hit to the different types of Google Analytics.