0

I need to include the google analytic code in my asp.net web page. But it doesn't track anything. I want to track the geolocation information , ipaddress, sessionid and browser information using google analytic. Here is my code ,

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

  (function (i, s, o, g, r, a, m) {
      i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
          (i[r].q = i[r].q || []).push(arguments)
      }, i[r].l = 1 * new Date(); a = s.createElement(o),
      m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
  })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

  var clientId , positionObj;
       ga(function (tracker) {
            clientId = tracker.get('clientId');
       });

       _gaq.push(['_setCustomVar',1, 'clientId','Premium', 1 ]);
       _gaq.push(['_setCustomVar',1, 'ipaddress','::1', 1 ]);

       _gaq.push(['_trackPageview']);

I referred the following link , https://developers.google.com/analytics/devguides/collection/gajs/

I want to track all the required changes in the page load.

3
  • 1
    That is the legacy javascript version, you should use the newest one: developers.google.com/analytics/devguides/collection/… I am not sure what you have done and what you haven't so lets cover the basics: 1) Have you made an analytics account? 2) Have you included the snippet in your html page? 3) Have you replaced it with your own id? 3) Have disabled your ad blocker when entering the page? Commented Feb 11, 2016 at 9:49
  • Thanks wobbly. I changed the code snippet and seems working. But how can I disabled ad blocker as you mentioned ? Commented Feb 11, 2016 at 13:25
  • That's only neccessary if you have a ad-blocker on your browser such as ad-block plus or uBlock Origins. If you don't then you should be fine. You can disable it for visiting users, so sadly those are "invisible" users. You can force users to disable ad-blockers before they can enter your site, or similar. However that's a completely different question. Do you see your usage statistics on the google analytics page? Commented Feb 11, 2016 at 13:27

1 Answer 1

1

That is the legacy javascript version, you should use the newest one: https://developers.google.com/analytics/devguides/collection/analyticsjs

I am not sure what you have done and what you haven't so lets cover the basics:

1) Have you made an analytics account?

2) Have you included the snippet in your html page?

3) Have you replaced it with your own id? 3) Have disabled your ad blocker when entering the page?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.