GoogleUniversalAnalytics Update is not called when GA is enabled

(Piotr Szal) #1

Continuing the discussion from GoogleAnalytics is called two times when page refresh:

The bugfix is nice, but what if I have both GoogleAnalytics and GoogleUniversal Analytics?
The GoogleUniversalAnalytics code is never called.

if (typeof window._gaq !== 'undefined') {
  pageTracker.on('change', function() {

// Also use Universal Analytics if it is present
if (typeof !== 'undefined') {
  pageTracker.on('change', function() {'send', 'pageview');

(Kane York) #2

I’m pretty sure you shouldn’t have both - pick one or the other.

(Jeff Widman) #3

Google is now pushing everyone to upgrade to Universal Analytics, so your best bet is to take your GA classic account (I forget what they call it) and migrate it to Universal. You won’t lose your data.

You don’t have to retag your site immediately, as the old tag will still push data to the Universal account. However, retagging with the newer JS code they give you will enable more features. For example, Universal GA allows you to tell Google when you know that multiple devices are the same user. So if you have someone logging into your forum from the desktop, and then from a mobile device, you can push into GA that it’s the same user–very, very handy from a marketing analytics perspective. I’m still coming up to speed on Discourse and haven’t looked at how to push that user id metadata back to Google from within Discourse. (And it’s tricky because Google is very explicit that you can’t use this to store PII in GA.)

That said, whenever I’m asked, I always tell people to use Google Tag Manager, and then pipe your Google Analytics tags through that. It’s far more powerful, especially if you have marketers who can’t touch the source code but want the ability to adjust analytics tags and remarketing pixels. I haven’t looked into implementing GTM within Discourse.

(Piotr Szal) #4

ok, but then GoogleUniversalAnalytics should be work properly :slight_smile:

Or I do misunderstand the location attribute. I will test it on a test GA account.

(Jeff Atwood) #5

Didn’t you fix this a while ago Sam?

(Sam Saffron) #6

Yes I am pretty sure I did.

(Sam Saffron) #7