Use Google Analytics in Non- web based application in .Net
Google analytics is contain valuable information that can be used to analyzing purposes. most of the time analytics used in web based applications. but analytics can be used in non web based applications too.
Send request to Google Analytics
as a first point u have to create Google analytics account. so first create Google analytics account and then login to it.
then agree to terms and conditions and create account.
after that in your application you need to you need to create URL as it calls in normal site. in here i use c#.
private void analyticsmethod4(string trackingId, string pagename)
{
Random rnd = new Random();
long timestampFirstRun,timestampLastRun,timestampCurrentRun,numberOfRuns;
// Get the first run time
timestampFirstRun = DateTime.Now.Ticks;
timestampLastRun = DateTime.Now.Ticks-5;
timestampCurrentRun = 45;
numberOfRuns = 2;
// Some values we need
// This can be calcualted for your domain online
string domainHash = "123456789";
int uniqueVisitorId = rnd.Next(100000000, 999999999); // Random
string source = "Sourcetesting";
string medium = "mediumTesting";
string sessionNumber = "1";
string campaignNumber = "1";
string culture = Thread.CurrentThread.CurrentCulture.Name;
string statsRequest = "http://www.google-analytics.com/__utm.gif" +
"?utmwv=4.6.5" +
"&utmn=" + rnd.Next(100000000, 999999999) +
"&utmcs=-" +
"&utmsc=-" +
"&utmul=" + culture +
"&utmje=-" +
"&utmfl=-" +
"&utmdt=" + pagename +
"&utmhid=1943799692" +
"&utmr=0" +
"&utmp=" + pagename +
"&utmac=" +trackingId+ // Account number
"&utmcc=" +
"__utma%3D" + domainHash + "." + uniqueVisitorId + "." +
timestampFirstRun + "." + timestampLastRun + "." +
timestampCurrentRun + "." + numberOfRuns +
"%3B%2B__utmz%3D" + domainHash + "." + timestampCurrentRun + "."
+ sessionNumber + "." + campaignNumber + ".utmcsr%3D" +
source + "%7Cutmccn%3D(" + medium + ")%7Cutmcmd%3D" + medium +
"%7Cutmcct%3D%2Fd31AaOM%3B";
using (var client = new WebClient())
{
client.DownloadData(statsRequest);
}
}