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 3310788
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:48:01+00:00 2026-05-17T21:48:01+00:00

I have a page like for example: http://www.stackoverflow.com/how-many-users-visited I have inside that page already

  • 0
  1. I have a page like for example: http://www.stackoverflow.com/how-many-users-visited

  2. I have inside that page already those google analytics javascript under my UA-0000-1 account.


    

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-xxxxxx-1']);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    
  1. Using http://www.google.com/analytics website tools i can see how many visitors came. To my specific url.

Now question:

I wan to use PHP or Javascript to do that query from my own to find those information and render it to my own page.

How can i get all the pages from google analytics using my account? Please kindly show some tips and example, this i tried but does not work.

ex: http://gdata-jsguide.appspot.com/static/analytics/samples/retrievedatacontent.js

  • 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-05-17T21:48:02+00:00Added an answer on May 17, 2026 at 9:48 pm

    To make sure i understand your question: you want to be able to get totals for pages viewed and unique visitors, but you want to store those data yourself rather than retrieve them from the GA server.

    So this just requires finding out how GA records for each page and then retrieving those values.

    Total pages viewed is easy–for a given page, just record each time _trackPageview() is called and take the sum.

    Total unique visitors is also easy but requires a few more steps.

    First, you need to know where GA holds this data.

    This is an exemplary request header for the tracking pixel (__utm.gif):

    http://www.google-analytics.com/__utm.gif?utmwv=4&utmn=769876874&utmhn=example.com&utmcs=ISO-8859-1&utmsr=1280x1024&utmsc=32-bit&utmul=en-us&utmje=1&utmfl=9.0%20%20r115&utmcn=1&utmdt=GATC012%20setting%20variables&utmhid=2059107202&utmr=0&utmp=/auto/GATC012.html?utm_source=www.gatc012.org&utm_campaign=campaign+gatc012&utm_term=keywords+gatc012&utm_content=content+gatc012&utm_medium=medium+gatc012&utmac=UA-30138-1&utmcc=__utma%3D97315849.1774621898.1207701397.1207701397.1207701397.1%3B...
    

    The utmcc portion of this header contains the GA cookies. Within utmcc, is utma which is the Visitor Cookie:

    This cookie is comprised of six fields, each delimited by a ‘.’

    97315849.1774621898.1207701397.1207701397.1207701397.1
    

    These fields are:

    1. Domain Hash (discard)

    2. Visitor ID (from a random number
      generator) this is the piece we
      want

    3. Initial Visit (a UNIX time stamp)

    4. Previous Session (also a UNIX time
      stamp)

    5. Current Session (also a UNIX time
      stamp)

    6. total number of visits (to pages
      having that GA Account number)

    So when a user visits a GA-tagged Site, GA looks for the cookies, which it updates; if GA doesn’t find them, it sets them.

    The second field in the utmaa cookie is the most important and the one that you want to grab. This is the ‘Visitor ID’ and it is a random number generated by GA, as a unique ID for each visitor. This cookie persists across sessions and expires two years from date set.

    This ID is not viewable in the GA Web Viewer, which means you need to capture it another way. Probably the easiest way is to just send it write a small javascript function to grab this string and bind it to a variable, and then you can just do what you want with it (bind it to a GA custom variable, place it temporarily in a hidden form field, etc.). So for instance:

    // takes three parameters: l-> target string; n -> start pattern; s -> end pattern
    // returns the visitor cookie (the entire cookie not just the second field)
    function vID(l, n, s) {
      if (!l || l=="" || !n || n="" || !s || s="") return "-";
      var i, i2, i3, c="-";
      i=l.indexOf(n);
      i3=n.indexOf("=")+1;
      if (i > -1) {
        i2=l.indexOf(s, i);
          if (i2 < 0) {
            i2=l.length;
          }
          c=l.substring((i+i3), i2);
       }
          return c;
    }
    
    var q = vID(document.cookie, '__utma=', ';');
    

    Once you have done this then you will have one visitor ID for each visitor–count them and you get total unique visitors (subject to all of the usual and substantial limitations inherent w/ cookies).

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

Sidebar

Related Questions

I have a page that is accessed via a URL like this: http://power-coder.net/Test/something.php?id=3#Page1 I
heres my setup: http://www.example.com/<module>/<controller>/<action> I have this route defined: $router->addRoute( 'editUser', new Zend_Controller_Router_Route('admin/users/edit/:id', array(
I'd like to have a page in php that normally displays information based on
I would like to have an aspx page that contains something like.... <form id=form1
Is there someway to have a part of the page that renders like a
hi is there a wait to load a full url.? url= 'http://www.example.com/whatever.php' $('#selector').load(url); //
I have a page which work like a navigation and a iframe in this
I have a page where I would like it to remain static after refresh
I have three tables: page, attachment, page-attachment I have data like this: page ID
I'd like to have an HTML page which displays a single PNG or JPEG

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.