GA has a new tracking system and will slowly do away with urchin.

This patch allows for legacy GA but defaults to the most recent GA script.

CommentFileSizeAuthor
updated_google_analytics.patch2.73 KBdavidburns

Comments

budda’s picture

Status: Needs review » Needs work

How does the segmentation and codesnippet stuff work with this new patch? It looks like you've not supported it in the new version?

budda’s picture

I've worked up some code based on the new Beta, it's in CVS now. However i've not had a chance to check it works - specifically with user segmentation and/or code snippets.

Please try and post here any problems.

budda’s picture

Status: Needs work » Fixed
Anonymous’s picture

Google has published a pdf guide to migrate from urchin.js to ga.js: http://www.google.com/analytics/GATCmigrationguide.pdf, a Guide to install the new tracking code: http://www.google.com/analytics/InstallingGATrackingCode.pdf and a analytics developer site: http://code.google.com/apis/analytics/

Hope this help

davidburns’s picture

Sorry budda, still getting used to submitting patches. I did a patch from what I had installed locally rather then what you had in cvs.

Thanks for updating.

hass’s picture

Priority: Normal » Critical
Status: Fixed » Needs work

1. The committed patch break the download tracker. Aside the noscript tags should be removed!

+      $script = '<script type="text/javascript" src="http' . $prefix . ".google-analytics.com/urchin.js\"></script>\n";
+      $script .= '<script type="text/javascript">' . "<!--\n_uacct = \"".$id."\";{$segmentation}{$codesnippet}urchinTracker();\n// --></script><noscript></noscript>\n";

2. and why are you adding <!-- ... --> to the second line?

3. Code Style is an issue here.

4. SSL example from the docs

<script type="text/javascript"> 	 
  var gaJsHost = (("https:" == document.location.protocol) ? 	 
  "https://ssl." : "http://www."); 	 
  document.write(unescape("%3Cscript src='" + gaJsHost + 	 
  "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); 	 
</script> 	 
<script type="text/javascript"> 	 
  var pageTracker = _gat._getTracker("UA-12345-1"); 	 
  pageTracker._initData(); 	 
  pageTracker._trackPageview(); 	 
</script> 	 

5. local cached copy is not implemented

6. googleanalytics_cron() downloads the wrong file to cache

7. Text constants need to be altered to reflect ga.js.

hass’s picture

#1 and #2 have some open questions.

D6: See http://drupal.org/cvs?commit=93222 where i fixed most of the above bugs.

hass’s picture

davidburns’s picture

Hey hass,

I want to make sure that my coding standards continue to improve. I'm reviewing my patch from your 7 comments listed above.

1. the comment out codes were in the module I was originally working on. I think my original patch shows that.

2. same as #1 I believe

3. refers to #2 & #4

4. My patch code looks nearly identical to what you have listed

5. Local cache copy? does this refer to #6.

6. googleanalytics_cron -> that function doesn't exist in the version I was working with.

7. I thought my submitted patch did reflect the ga.js
document.write("\<script src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'>\<\/script>" );

So my question is.... did your list really apply to my patch or something else. As you can tell I'm somewhat confused.

Thanks!

hass’s picture

Your patch above was outdated when it was comitted and has been reroled with bugs.

I think budda added your changes, but re-introduced bugs (for e.g. #1: noscript tags) fixed earlier but after you created your patch... that's the main problem i think. Now it's more a follow up to fix bugs introduced by this committ and to add some missing/incomplete parts.

davidburns’s picture

Thanks for clarifying that. I was really thrown off by not using the most current version.

Since the code has been committed, should this thread still be status: code needs work?

hass’s picture

yes, the committed patch is buggy, so needs work.

micahw156’s picture

subscribing

Duplika’s picture

Suscribing.

rickvug’s picture

subscribing.

tanc’s picture

Will the new GA code be able to be cached by this module, like the legacy urchin code can be?

hass’s picture

Yes. D6 already caches both, D5 need to be fixed.

budda’s picture

Cache now downloads the old or new GA file depending on the legacy setting.
Cron now clears the right file.

hass’s picture

Status: Needs work » Fixed

All from #6 should be fixed now.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.