Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8673241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:24:29+00:00 2026-06-12T19:24:29+00:00

i want to send request to Google analytics in non web based application(Windows based

  • 0

i want to send request to Google analytics in non web based application(Windows based application) ?
i tried following method.

public string  trackingId = "UA-XXXXXXXX-2";

private void button1_Click(object sender, EventArgs e)
{
    string shopname = "ShopTestng";
    string pagename="Testing_MyApp";
    callAnalyticsmethod2(pagename, shopname);
}

private void callAnalyticsmethod2(string pageName, string shopname)
{
    // create hash code base on pc name 7 user name    
    string visitorId = GetUniqueUserId(); 
    if (string.IsNullOrEmpty(pageName))
        pageName = visitorId;

    string utmGifLocation = "http://www.google-analytics.com/__utm.gif";

    string GifUrl = "utmwv=4.9" +
        "&utmn=" + GetRandomNumber() +
        "&utmp=" + pageName +
        "&utmac=" + trackingId +
        "&utmcc=__utma%3D999.999.999.999.999.1%3B" +
        "&utmvid=" + visitorId;// + "?" +

    string shop = shopname.Replace(" ", "_");
    string addipara = GifUrl+"&utmr=http://" + shop;

    byte[] dataStream = Encoding.UTF8.GetBytes(addipara);

    string request = utmGifLocation;

    WebRequest webRequest = WebRequest.Create(request);
    webRequest.Method = "POST";
    webRequest.ContentType = "application/x-www-form-urlencoded";
    webRequest.ContentLength = dataStream.Length;
    Stream newStream = webRequest.GetRequestStream();
    // Send the data.
    newStream.Write(dataStream, 0, dataStream.Length);
    newStream.Close();
    WebResponse webResponse = webRequest.GetResponse();
    MessageBox.Show((((HttpWebResponse)webResponse).StatusDescription));

    newStream = webResponse.GetResponseStream();
    StreamReader reader = new StreamReader(newStream);
    string responseFromServer = reader.ReadToEnd();
    MessageBox.Show(responseFromServer);

    reader.Close();
    newStream.Close();
    webResponse.Close();
}

according to the above code sample

MessageBox.Show((((HttpWebResponse)webResponse).StatusDescription));

line display as “OK”. but when i check Google analytics, visit count doesn’t increase. what is the reason for this?
is there something i missing or any other way to send request to analytics?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:24:30+00:00Added an answer on June 12, 2026 at 7:24 pm

    i found similar answer from SOF (Cause Google Analytics log from non-web application and editted it according to my scenario.

        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
            string domainHash = "123456789"; // This can be calcualted for your domain online
            int uniqueVisitorId = rnd.Next(100000000, 999999999); // Random
            string source = "Shop";
            string medium = "medium123";
            string sessionNumber = "1";
            string campaignNumber = "1";
            string culture = Thread.CurrentThread.CurrentCulture.Name;
            string screenRes = Screen.PrimaryScreen.Bounds.Width + "x" + Screen.PrimaryScreen.Bounds.Height;
    
    
            string statsRequest = "http://www.google-analytics.com/__utm.gif" +
                "?utmwv=4.6.5" +
                "&utmn=" + rnd.Next(100000000, 999999999) +
            //  "&utmhn=hostname.mydomain.com" +
                "&utmcs=-" +
                "&utmsr=" + screenRes +
                "&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);
                //Stream data = client.OpenRead(statsRequest);
                //StreamReader reader = new StreamReader(data);
                //string s = reader.ReadToEnd();
            }
    
        }
    

    I found good Articles about –

    Google Analytics for Desktop Application

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to refresh Google Map and send new geolocalization request without refreshing the
I want to send a request to the google places (not google place API),
I want to send Ajax request to controller, I make like this in the
I want to send a request to another server from my servlet and get
In python, I want to send a request to a url which will return
I want tot send a friend request using the Facebook Android SDK. I'm currently
So all I want to do is send a POST request to a url.
I'm writing an Android application that I want to be able to send requests
I'm using Django with Google's App Engine. I want to send information to the
This is what I want to do: I want to send an HTTP request

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.