Support latest Google Analytics code

AntoineSolutions - July 8, 2008 - 22:06
Project:Ubercart
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

This patch adds support for the latest Google Analytics code. It gets which code to use from the Google Analytics module.

AttachmentSize
uc_googleanalytics_latest.patch3.6 KB

#1

rszrama - July 9, 2008 - 21:06

Played with the patch a touch... seems like I had to change

<?php
 
if (variable_get('googleanalytics_legacy_version', 0)) {
?>

to

<?php
 
if (variable_get('googleanalytics_legacy_version', TRUE)) {
?>

for it to work properly on the older version of GA. Sound right?

#2

AntoineSolutions - July 9, 2008 - 21:55

Not sure why you had to change this? If I am not mistaken, the second parameter of the variable_get function is simply a default value to be used in case there is no value currently stored for the variable. If the case is that there is no value stored for the variable, I figured we should use the same default as the google_analytics module which I believe is found on line 381 of the googleanalytics.module file, ver 5.x-1.6.

    '#default_value' => variable_get('googleanalytics_legacy_version', 0),

I have tested the patch with the latest version of the google_anatlycis module 5.x-1.6. When switching between the latest/legacy google analytics code, the correct text is rendered. Perhaps this is a version issue? What version of the google_analytics module are you using?

Cheers,

Jon Antoine
www.antoinesolutions.com

#3

rszrama - July 9, 2008 - 22:18

Well, I was working on an older version of the Google Analytics module. Since that variable hadn't been defined yet, it was using the 0 default. This means it wasn't using the legacy code but the new code... which of course wouldn't work.

I figured it would be ok to go against their default b/c anyone new who uses the module will have that variable set for them. I'm not sure if GA sets that variable on an update, though... but those folks will just have to go submit the form if they want the new code.

#4

AntoineSolutions - July 14, 2008 - 17:51

OK,

After some testing I agree with rszrama's change. Once the GA module is installed, the user must configure it by putting in their GA account number before it is active causing the "googleanalytics_legacy_version" variable to be set. I have attached an updated patch.

Cheers,

Jon Antoine
www.antoinesolutions.com

AttachmentSize
uc_googleanalytics_latest.patch 3.62 KB

#5

rszrama - July 14, 2008 - 21:10
Category:support request» feature request
Status:needs review» fixed

Committed. Thank you!

#6

Anonymous (not verified) - July 31, 2008 - 04:47
Status:fixed» closed

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

#7

neochief - September 1, 2008 - 11:40

Hello guys!

This code isn't work with 2CO payment module, because it doesn't uses "cart/checkout/complete" page for order completion. It uses "cart/2checkout/complete", because of special handling of 2CO orders. My simple patch resolves this problem. It removes single non-critical args check, so GA in 2CO's completion page will work fine.

AttachmentSize
2CO_uc_googleanalytics.module.patch 696 bytes

#8

neochief - September 1, 2008 - 11:40
Status:closed» needs review

#9

greggles - September 4, 2008 - 22:28
Assigned to:AntoineSolutions» Anonymous
Status:needs review» needs work

The patch needs work - it has the addition of two if lines rather than the removal of one and addition of one. As written, it fails to apply.

#10

neochief - September 7, 2008 - 13:07
Status:needs work» needs review

Oh, sorry, my bad. Here is the right one

AttachmentSize
2CO_uc_googleanalytics.module2.patch 696 bytes

#11

rszrama - January 9, 2009 - 15:43
Version:5.x-1.0» 6.x-2.x-dev
Status:needs review» fixed

This issue was originally related to just making sure we support the latest GA code. It was marked as fixed, and I think neochief is raising a separate issue. However, I am doing some work and decided instead to use a hook that determines whether or not to display the UC GA JS (holy acronyms, Batman!) for now. The hook is hook_ucga_display(), and it will only be invoked if the original conditions fail. Modules simply return TRUE or FALSE to indicate whether or not this is the page that the UC GA JS should be displayed.

I'm marking this fixed for 6.x and 5.x; the code will be committed and made available in the next releases.

#12

rszrama - January 9, 2009 - 15:53

The patch to check out is attached.

AttachmentSize
hook_ucga_display.patch 2.54 KB

#13

System Message - January 23, 2009 - 16:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.