Running Drupal 5.2 and GA module 1.x-dev with the module activated and my theme containing the required print closure I am not seeing google urchin.js code being inserted. I have double checked the module is activated and the config is saved. The site is at nisekonews.com. Any thoughts?

Getting the same results with the 1.x-dev version released a day later than the 1.3 version.

I have a patch installed to monitor module memory usage which prints lines after the end of the html tag but this should not interfer with javascript being inserted by your module.

Cheers

Comments

budda’s picture

Has your theme got the print $closure; in it?

GioSico’s picture

my theme contain(s) the required print closure.

GioSico’s picture

I also tried the default garland theme and still get the same problem.

sebzur’s picture

Exactly the same problem.... Any suggestion is welcome!

GioSico’s picture

I moved the module from the google_analytics folder to the googleanalytics folder and that does not fix the problem.

My theme does contain the $closure variable and a $footer_message variable but no $footer variable. I mention this as some of your other support requests are unclear about this. Even though the README is clear.

Any thoughts? Again http://www.nisekonews.com

Cheers

Beau Gunderson’s picture

I'm seeing this on 6.x-dev. Will investigate and report back.

Beau Gunderson’s picture

Category: support » bug
Status: Active » Needs review
StatusFileSize
new1.35 KB

This appears to be a bug where the test for variable_get is inverted in two cases.

I'm attaching a patch against 6.x. It may not apply cleanly against 5.x as there are a couple of other tiny fixes in this patch. If you are experienced with PHP you should be able to apply it manually, it's the two lines in the patch containing "variable_get".

I'm unfamiliar with module bugs; do they usually get cloned if they're present in more than one version?

GioSico’s picture

Thanks for the patch ... I will see about applying it to my version ... and report back in a few days ...

GioSico’s picture

I applied portions of your D6 patch and my D5 google analytics module now works. Thank you.

Here is a patch I created but have not tested the patch itself. So use at your own risk and of course make backups first

--- googleanalytics.module.orig 2007-10-11 09:28:13.000000000 +0400
+++ googleanalytics.module 2007-10-11 09:36:25.000000000 +0400
@@ -44,12 +44,12 @@
// Check if we should track the currently active user's role
$track = TRUE;
foreach (array_keys($user->roles) as $role) {
- if (variable_get('googleanalytics_track_'. $role, FALSE)) {
+ if (!variable_get('googleanalytics_track_'. $role, FALSE)) {
$track = FALSE;
}
}

- if ($user->uid == 1 && variable_get('googleanalytics_track__user1', FALSE)) {
+ if ($user->uid == 1 && !variable_get('googleanalytics_track__user1', FALSE)) {
$track = FALSE;
}

budda’s picture

Committed to Drupal5 branch.

hass’s picture

Status: Needs review » Fixed

Committed to Drupal6 branch.

colorado’s picture

Version: 5.x-1.3 » 5.x-1.x-dev
Status: Fixed » Active

I've updated to the current 5.x dev version which has the patch applied, and I have the closure code in the footer, but still no javascript is being inserted, and I can't get the module to work.

I found this http://drupal.org/node/150421#comment-240466 which suggests to put the Analytics code into a block and put the block to the footer of all pages.

Has anyone tried this with any success?

svogel’s picture

Might it be that simply the variables are wrongly set?
When I look at the config-page it says:
"Define what user roles should not be tracked by Google Analytics."
But the variables (see table variables): googleanalytics_track_* are set to 1 if the checkbox is set and 0 if it's not.
So if one would change the text to:
"Define what user roles should be tracked by Google Analytics."
than it works.

Best regards
Stefan

robertgarrigos’s picture

That's exactly what's happenning. The user role tracking settings for this module are just working the other way round, at least for the roles listed there. User 1 is never tracked which ever has in it. You should either change that frase and leave user 1 out of it or fix the code to work as it used to.

xl-network’s picture

Same here. When I checked all the boxes (for all the roles), it was working...

robertgarrigos’s picture

Priority: Normal » Critical

I change this to critical as this module stops working when updated. Please, either change the frase on settings page or return to former functionality because if you use cvs (as I do) to update your modules from your website, this module just stops working and, what is worst, apparently everything looks the same, so webmaster can be very confused. This means that right now, hundreds of sites using this module, if updated, are not working.

nrambeck’s picture

Here's an overview of the problem in the current 5.x dev version:

The settings form for this module asks which Roles NOT to track. If a user checks the "Anonymous" role (role #1) then it sets a variable called "googleanalytics_track_1" to TRUE. This is counter-intuitive because the user just indicated he DOES NOT want to track this role yet the variable name indicates that he does want to track the role. The variable name should be changed to "googleanalytics_notrack_1", to prevent the current bug in the sytem.

The current bug is located in the googleanalytics_track() function:

  foreach (array_keys($account->roles) as $role) {
    if (!variable_get('googleanalytics_track_'. $role, FALSE)) {
      $track = FALSE;
    }
  }

  if ($account->uid == 1 && !variable_get('googleanalytics_track__user1', FALSE)) {
    $track = FALSE;
  }

The above code is assuming that if "googleanalytics_track_1" is set to FALSE, then we should not track this page. This is a good assumption based on the language of the variable, but it is wrong because the variable is set using the exact opposite logic.

I propose that all instances of "googleanalytics_track_" be changed to ""googleanalytics_notrack_" and that the above code be modified to remove the "!" in front of each variable_get() function.

underpressure’s picture

Subscribing - same issue :(

I also get this error: Validation error, please try again. If this error persists, please contact the site administrator.

nicholasthompson’s picture

Same issue - I thought I was going logically insane... I've read that decscription in form dozens of times now, always confirming that I had just read "NOT"... :-)

brianpkennedy’s picture

I faced this problem this morning and faced 2 problems:

1) the not track/track problem

2) I was using a custom theme that was not properly set up to call hook_footer(). Our theme_closure output a standard footer with links, and I updated it with

   $footer = module_invoke_all('footer', $main);
    return implode("\n", $footer) . drupal_get_js('footer').$footer_links;
    

Hope this helps, this problem seems to be documented in multiple tickets.

robloach’s picture

Status: Active » Closed (duplicate)

I posted a patch that fixes the logic here. If you guys would mind setting it to RTBC, I could commit it there, and then take a look at the Drupal 5 port of the patch.

robertgarrigos’s picture

I tried your patch for drupal 6 and think is RTBC. Would you port it to drupal 5?