It seems that after updating the google analytics module to version 2.0 that ga_tokenizer isn't working anymore. Since the update I receive empty GA information tables below my sent webforms. Does ga_tokenizer fully support version 2.0 of the google analytics module, or are there more users that experience problems like this?

Comments

Brian294’s picture

Thank you for reporting the issue.

Believe it or not, GA Tokenizer is completely independent of the Google Analytics module (even though I made the GA module a dependency). GA_Tokenizer reads the cookie set by the Google Analytics javascript provided by Google. If you are seeing blank values, it would suggest that:
1. Google Analytics cookies are not being set at all -- perhaps the GA script is not being inserted into the rendered html?
2. Google might have changed the format of their cookie and those values are no longer present.

If it is #2, then I would expect to see a lot of tickets to be opened in the near future from everyone using GA.

Can you do a View Source on your web page to confirm that you see ga.js in the code and that no javascript errors are occurring? Chrome has a nice tool. Right click on a page an choose "Inspect Element" to see the developer console.

Peace,
Brian

Rob1106’s picture

Hi Brian,

thanks for your quick reply. Somehow I did not receive a notification or I would've responded earlier. But I know the problem already then. Because the new google analytics code (and therefore the GA module) does not use ga.js anymore. It uses analytics.js.

Checking our website confirms my suspicion, it is using analytics.js...

Rob1106’s picture

Where you able to reproduce the problem? I haven't seen any other users here with the same problem, but the switch to the new analytics.js cookie instead of the old ga.js cookie is for everyone. It is a part of the major upgrade to the new analytics code since Q2 this year I believe. Hopefully this won't complicate things too much at the code level...

andygradel’s picture

I'm experiencing the same thing. Tokenizer is no longer working for me after upgrading to GA 2.0...

andygradel’s picture

Actually, my apologies as I went through a bunch of settings on my set and it appears to have been a block caching issue on my end.

Rob1106’s picture

It still is not working on my installation. Anyone that has any pointers? There are no settings that could be wrong somewhere, or are there?

redlow’s picture

My understanding is that it's #2, per Brian's original follow-up questions. The new universal analytics script does not store Campaign, Source, etc etc in the user's cookie. Instead, they are using a remote database.

I've ran into this issue a lot this year with new GA scripts and especially Tag Manager. My current work-around is to use the old, deprecated version of GA (manually added, not via the module) along side the new version, using two different GA account numbers.

Rob1106’s picture

I tried your solution and it gets the form data back again. However I use cross-domain tracking, and it breaks some of those cross-domain links unfortunately. They end up as dead links somehow. Will post more when I figure this out.

Edit:
Figured it out. There were some old hardcoded cross-domain tracking links in our website (from the old GA code where this couldn't be tracked automatically). Those links broke down when using both the old and the new GA code simultaneously. So after deleting the hardcoded links everything works like a charm again.

So I can confirm the solution:

  1. Use the new GA code inside your GA Drupal module.
  2. Add a version of the old GA code on every page of your website.
jlea9378’s picture

I have already upgraded my GA property to UA, so I don't know what my "old code" is. Can you provide an example? Thanks!

redlow’s picture

Hmm.. Old GA analytics code:

You can visit the google_analytics module page (https://www.drupal.org/project/google_analytics) and look at the old releases. You could probably pick it out from there. Sorry I can't be a little more helpful.. pressed for time at the moment, but wanted to try to give you a point in the right direction.

jlea9378’s picture

Thanks I was able to bring up my old site and get the code.

For anyone interested here is what it looks like:
<script>var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-XXXXXXX-Y"]);_gaq.push(["_setDomainName", "www.example.com"]);_gaq.push(["_trackPageview"]);(function() {var ga = document.createElement("script");ga.type = "text/javascript";ga.async = true;ga.src = ("https:" == document.location.protocol ? "https://" : "http://") + "stats.g.doubleclick.net/dc.js";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga, s);})();</script>

I put this code in the HEAD section of my theme html.tpl.php file. Is this right? It looks like it is working.

redlow’s picture

I thought I'd give some insight to future people trying to figure this issue out. I've worked out an alternative that checks utm_parameters and/or attempts to infer source&medium from HTTP_REFERER. It saves it all in a cookie to be used in tokens. It's undeniably not as good.

There's a couple other alternatives around, such as this one:
https://github.com/dm-guy/utm-alternative/

Very similar solution, although js-based. In both cases, inferring source and medium can be tricky (What you would previously see as organic/direct/referral/cpc). Referrals from HTTPS sites like facebook and twitter are very problematic because HTTPS sites do not transfer HTTP_REFERER information.

Installing Universal and regular analytics still works, at least for now (who knows when support for ga.js will be dropped)
http://stackoverflow.com/questions/18604715/google-analytics-missing-utm...

jason ruyle’s picture

I put in the utm-alternative approach, but found there would be a lot of extra work to get that setup working properly with all the other token modules that coincide with this module.

I ended up putting the following code on my site, I do have to check to see if its going to double my traffic, but hopefully not.
Once this was on the site things started to work properly. I now run the google_analytics module (universal) and have this snippet running for tracking purposes.
Please note that I grabbed the __utm.gif file from google as well and stored in my theme. I believe this is just a blank.gif file.

  <script>
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', "UA-XXXXXXXX-X"]);
    _gaq.push(['_setDomainName', "SITENAME.com"]);
    _gaq.push(['_setAllowAnchor', true]);
    _gaq.push(['_setLocalGifPath', "http://PATHTOTHEME/images/__utm.gif"]);
    _gaq.push(['_setLocalServerMode']);
    _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);
    })();
  </script>
Anonymous’s picture

This is a huge bummer. Maybe this should be listed as a 'known issue' on the main module page since I ran into this problem in the past couple days while setting up the module for the first time.

dsnopek’s picture

I created a quick sandbox module to replace this one because of this problem:

https://www.drupal.org/sandbox/dsnopek/2844722

It basically just puts the utm_* stuff in a custom cookie, and then grabs the info from it for some tokens