0

I have been trying to get Google Analytics (Universal) working across two related domains, say www.foo.com and app.foo.com.

According to the Google Docs, I should be able to use the Universal code with domain 'auto' and it should just work.

I did the standard tracking codes in both sites (ID changed):

<script>
(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');

ga('create', 'MY-CODE-1', 'auto');
ga('send', 'pageview');

I have two problems:

  1. When I go to "Real-Time" pane, I see the visitor count and page visited correct when I go to a page in the www site, but nothing for the app. site.
  2. I cannot get it to show me the domain name of the page visited. I tried using custom filters on the global view per https://support.google.com/analytics/answer/1034342?hl=en#Next but it makes no difference.

What am I doing wrong?

  • Did you check with analytics debugger, wasp or a cookie manager that in your subdomain analytics is actually working? – lucgenti Jun 11 '15 at 9:42
  • As I show my ignorance and say, "if they were server-side code or my own JS, I would know how to, but I don't know how to debug if analytics is working." My basic guess would be to check if requests of some kind to Google, but.... – deitch Jun 11 '15 at 9:45
  • OK, good point. Fired up in Firefox (pun intended). www site is showing, after loading the analytics.js, that it is doing a GET for google-analytics.com/collect?<lots of params> The same does not happen on app. – deitch Jun 11 '15 at 9:47
  • That means there's some problem in the implementation. Look at the differences between analytics in www and in app. Even in where are positioned on the page (but they should be both before the closing <head> tag). – lucgenti Jun 11 '15 at 9:50
  • 1
    @lucgenti right you are. Please put that up as an answer and I will accept it. Once I did it, I saw that the app had a condition for the tracking code (avoid localhost because of dev) that was backwards. – deitch Jun 11 '15 at 9:54
1

With analytics.js, there's no need to do more.

So, first thing to check is the implementation of the code.

One good way is to use the official Google Analytics Debugger for Chrome https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting#usingDebugger Then activate it, open up the console with F12 and see if the code is working, like this:

Google Analytics Debugger for Chrome example

If Initializing Google Analytics isn't present, here's the problem. So, look back to both the script and see what could be the differences between the working one and the other.

  • Thanks, this was really helpful. The send was not getting sent. – deitch Jun 11 '15 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.