Reading the old __utmz values with analytics.js

4,190 views
Skip to first unread message

Cornelis Poppema

unread,
Nov 11, 2013, 2:24:22 PM11/11/13
to google-analyti...@googlegroups.com
Hello everyone, 

I've only recently started with using ga.js in the most basic way: including it and pushing a function to _gaq to read the latest __utmz cookie to send this to my own application for post processing. The only part of the __utmz cookie which I care about is the part after the 4 numbers, i.e. utmscr, utmccn, utmcmd, utmctr etc. I've recently adopted my script to use analytics.js instead of ga.js and it still seemed to work, I was able to read the __utmz values by using the following code:

ga(function(tracker) {
            /* read utmz from tracker */
            make_call(tracker.get('_utmz'));
});

However, when I removed ga.js completely I noticed __utmz was no longer avaiable AND tracker.get('_utmz') was no longer available. I searched since then to a solution to my problem, if there was a way within tracker to scramble together these variables available in the old __utmz cookie, but all I found was tracker.get('referrer') to give me back utmscr and no means to read the others. Is there a way to read these values or do analytics.js and ga.js co-exist and do I have to insert ga.js back into my pages?

Thanks beforehand!

Frank B.

unread,
Nov 11, 2013, 3:23:36 PM11/11/13
to google-analyti...@googlegroups.com
Hi, with analytics.js this is not possible anymore - at least not currently. Take a look at this discussion: https://groups.google.com/forum/#!topic/google-analytics-analyticsjs/NtwQFQAZ2Oo

Cornelis Poppema

unread,
Nov 12, 2013, 1:28:27 PM11/12/13
to google-analyti...@googlegroups.com
Thank you Frank. Since I really do need this information, you think I can keep using ga.js for this or is it being deprecated in the near future ?

Sebastian Breidert

unread,
Nov 13, 2013, 6:38:38 AM11/13/13
to google-analyti...@googlegroups.com
Hi Cornelis, see https://developers.google.com/analytics/devguides/collection/upgrade/:

Universal Analytics will become the new operating standard for Google Analytics and all Google Analytics properties will soon be required to use Universal Analytics. Any properties that don’t follow the upgrade process will be auto-transferred to Universal Analytics in the future. You will not receive notification prior to the auto-transfer, but will see a status message on the tracking code page in their accounts regarding the progress of the upgrade. You can implement a version of the Universal Analytics tracking code when your property transfer is complete. Properties containing profiles that use the dc.js JavaScript snippet and any related reporting or remarketing features will not be auto-migrated until those features are supported by Universal Analytics. But all product updates and new features will only be available to Universal Analytics properties. Data collected from ga.js will be processed for a minimum of 2 years after Universal Analytics has become the new operating standard, at which time all non-Universal Analytics collection methods will be deprecated and no longer work.

Cornelis Poppema

unread,
Nov 13, 2013, 7:52:49 AM11/13/13
to google-analyti...@googlegroups.com
Yes, thank you, but if I have a local ga.js does this mean it simply won't report to google or will it stop working, I don't know how the mechanics work internally and if there are dependencies besides hosting the ga.js that will prevent setting a __utmz cookie after 2 years or wether Universal Analytics will have support to read these values by then, that is the last answer I'm looking for right now.

Op woensdag 13 november 2013 12:38:38 UTC+1 schreef Sebastian Breidert:

Sebastian Breidert

unread,
Nov 13, 2013, 8:57:23 AM11/13/13
to google-analyti...@googlegroups.com
If you would host ga.js locally the script would still work and set the __utmz cookie, just the requests to the Google Analytics servers would not be processed anymore.

Arulmurugan S

unread,
Jun 30, 2014, 3:26:09 AM6/30/14
to google-analyti...@googlegroups.com, c.po...@gmail.com
Did you resolve the issue? I am having same issue.. Thanks

Cornelis Poppema

unread,
Jun 30, 2014, 3:43:50 AM6/30/14
to google-analyti...@googlegroups.com, c.po...@gmail.com
Not resolved as in finding a way to use only analytics.js for my needs. I just tell my customers to have at least ga.js on their websites to use my services. If they want to use analytics.js for themselves for any custom metrics or w/e, they just need to use both on their website. As far as I figured out 'ga.js' is the only one of these two that sets the utmz-cookie

I do use detection of either one in my scripts with the following code:

if(typeof window.ga != "undefined" ) {
    ga(function(tracker) {
        var utmz = tracker.get('_utmz');
        do_function(utmz);
    });
} else {
    if(typeof window._gaq != "undefined") {
        window._gaq.push(function() {
            var utmz = read_cookie('__utmz');
            do_function(utmz);
        });
    }
}

NOTE: 'read_cookie' and 'do_functions' are functions you'll need to write yourself.

Op maandag 30 juni 2014 09:26:09 UTC+2 schreef Arulmurugan S:

Arulmurugan S

unread,
Jun 30, 2014, 3:57:35 AM6/30/14
to Cornelis Poppema, google-analyti...@googlegroups.com
Thanks for reply!

I have planned to use just analytics.js and have to resolve CRM dependency using _utmz cookie.

are you hosting ga.js in local?

In this case, do I have to use just below part of your code? 

if(typeof window.ga != "undefined" ) {
    ga(function(tracker) {
        var utmz = tracker.get('_utmz');
        do_function(utmz);
    });
}

Appreciate your help! thanks.


--
You received this message because you are subscribed to a topic in the Google Groups "google-analytics-analyticsjs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-analytics-analyticsjs/0ltRStPAn8M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-analytics-ana...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cornelis Poppema

unread,
Jun 30, 2014, 4:11:02 AM6/30/14
to google-analyti...@googlegroups.com, c.po...@gmail.com
It doesn't really matter right now whether you'd host it locally or not. It just needs to be loaded regardless. I do believe Google was supposed to stop support for Classic GA in favor of UA, but I'm not sure if that means they'd stop hosting ga.js.

> If you send data to a Universal Analytics property using a classic Google Analytics collection method (like the ga.js JavaScript library), your data will be processed during the phases of the upgrade. Your data will not be processed, however, after the classic Google Analytics libraries and SDKs have been deprecated.

To be on the safe side, you can host ga.js locally either way. I don't know if or how often ga.js is still updated, but you would have to check for changes manually (just download the ga.js from google once in a while and replace your local version).

I interpret this as they still create and update the same cookies (like __utmz), but that the AJAX calls it executes simply become void.

Op maandag 30 juni 2014 09:57:35 UTC+2 schreef Arulmurugan S:
To unsubscribe from this group and all its topics, send an email to google-analytics-analyticsjs+unsub...@googlegroups.com.

Arulmurugan S

unread,
Jun 30, 2014, 5:24:57 AM6/30/14
to Cornelis Poppema, google-analyti...@googlegroups.com
Thanks for the details. I couldn't understand the below point.

"I interpret this as they still create and update the same cookies (like __utmz), but that the AJAX calls it executes simply become void."

How will it become void?



To unsubscribe from this group and all its topics, send an email to google-analytics-ana...@googlegroups.com.

Cornelis Poppema

unread,
Jun 30, 2014, 7:44:22 AM6/30/14
to google-analyti...@googlegroups.com, c.po...@gmail.com
As I read it: if you have a working copy of ga.js, it'll still try to send data to Google. However, if at some point they finally stopped supporting ga.js (Classic GA) and only accept analytics.js (UA), they won't accept / do anything with this data - they will only process data posted by analytics.js

Again; this is how I interpret that article.

Op maandag 30 juni 2014 11:24:57 UTC+2 schreef Arulmurugan S:
To unsubscribe from this group and all its topics, send an email to google-analytics-analyticsjs+unsubs...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Arulmurugan S

unread,
Jun 30, 2014, 7:47:14 AM6/30/14
to Cornelis Poppema, google-analyti...@googlegroups.com
Thanks a lot for the details. I shall update once I try it out.


To unsubscribe from this group and all its topics, send an email to google-analytics-ana...@googlegroups.com.

Arulmurugan S

unread,
Jul 1, 2014, 7:02:46 AM7/1/14
to Cornelis Poppema, google-analyti...@googlegroups.com
I am hosting ga.js in my local. It seems to be working. However there are 2 pageview requests to google. 1 from ga.js and another 1 is from analytics.js.

I have commented part of ga.js which sends ajax request. It looks good now. 

I like to comment out the functions which is not used for setting the cookies. Appreciate if you could advice and thoughts about it. Thanks. 

Michael Ha

unread,
Jul 24, 2014, 2:19:35 PM7/24/14
to google-analyti...@googlegroups.com
I'm running both ga.js and analytics.js so that I can read the _utmz cookies. However, the bounce rate has dropped from ~60% to 5%.  Appreciate if you have any advise/idea to fix this. Thanks.

Colin Greig

unread,
Oct 21, 2014, 1:42:14 PM10/21/14
to google-analyti...@googlegroups.com, c.po...@gmail.com
Can you share your version of ga.js with ajax requests commented out? 


On Tuesday, July 1, 2014 4:02:46 AM UTC-7, Arulmurugan S wrote:

Niamh Phelan

unread,
Feb 10, 2015, 11:35:06 AM2/10/15
to google-analyti...@googlegroups.com, c.po...@gmail.com
Hi all

Just encountered the same issue, if I understand you guys want to grab some data out of cookies but analytics.js does not set cookies so you host ga.js locally until such a time as Google stop taking data from ga.js when you need a new solution.

I'd like to even be able to view what is being sent to GA in the cookies, for debugging etc.

I have observed issues with referral data on sites that mixed the (very old) urchin.js and ga.js. So I have seen mixing the tracking code versions, result in self referrals (i.e. when a site is its own referrer, source=mydomain.com)., because somewhere mid visit the original referrer gets overwritten with mydomain.com so you lost important data. With analytics.js they say to just add mydomain.com as a Referrer Excluded, I am sure this works and stops any over-writing but I would rather know that my multi-trackers are working correctly.
https://support.google.com/analytics/answer/3198398?hl=en

Have you encountered this?

Many thanks
Niamh
Reply all
Reply to author
Forward
0 new messages