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.
| Attachment | Size |
|---|---|
| uc_googleanalytics_latest.patch | 3.6 KB |

#1
Played with the patch a touch... seems like I had to change
<?phpif (variable_get('googleanalytics_legacy_version', 0)) {
?>
to
<?phpif (variable_get('googleanalytics_legacy_version', TRUE)) {
?>
for it to work properly on the older version of GA. Sound right?
#2
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
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
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
#5
Committed. Thank you!
#6
Automatically closed -- issue fixed for two weeks with no activity.
#7
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.
#8
#9
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
Oh, sorry, my bad. Here is the right one
#11
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
The patch to check out is attached.
#13
Automatically closed -- issue fixed for two weeks with no activity.