Installed google_analytics in Drupal 6.0-beta2 and set the GA ID.

No GA code appears, even for non-admin and anonymous users.

Didn't see any error messages in the logs.

I tried "Cache urchin.js locally" on and off.

Theme Garland is active with < ? php print $closure ?>

http://ftp.drupal.org/files/projects/google_analytics-6.x-1.x-dev.tar.gz
// $Id: googleanalytics.module,v 1.14.2.13 2007/08/27 21:21:25 budda Exp $

Any idea of what is wrong?

Comments

bluepuma’s picture

Category: support » bug
Priority: Normal » Critical

Module dooesn't work - at least according to the settings.

I searched around and this (http://drupal.org/node/179026) proves to be true:

"Define what user roles should not be tracked by Google Analytics."

has to be reworded to

"Define what user roles should be tracked by Google Analytics."

Then it works as planned.

Who will fix this in the CVS?

duntuk’s picture

thanks bluepuma... it worked after checking the boxes....

yeah, that's pretty retarded wording... it should definitely be reworded...

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

Confirmed that the tracking code isn't being inserted..... http://www.robloach.net . The module is enabled and the account configuration is setup properly.

robloach’s picture

Status: Active » Needs review
StatusFileSize
new1.47 KB

It seemed it was a documentation/design issue.... This patch should fix it.

budda’s picture

Somebody else submitted the patch for Drupal 5 with the retarded wording and inverted logic. I agree that it doesn't "feel" natural - but all the code in the patch was working that way.

The other issue with the setting just not working in the D6 branch was also fixed in the D5 branch a while ago -- i just haven't been involved in the D6 branch yet. I thought Hass was handling it.

robloach’s picture

Well, this patch fixes it. I'm not sure what the status is for the Drupal 5 branch, but this fixes it for Drupal 6. I'll stick it into the CVS the issue is given a RTBC.

hass’s picture

Status: Needs review » Needs work

@Rob: This is not correct... "core" line is added by packaging. And the double quotes are not necessary. Remove both lines from your patch, please.

+description = "Adds Google Analytics javascript tracking code to all your site's pages."
+core = 6.x
robloach’s picture

Status: Needs work » Needs review
StatusFileSize
new835 bytes
robertgarrigos’s picture

great, this fixes the problem. for me it's RTBC

robloach’s picture

Status: Needs review » Reviewed & tested by the community
hass’s picture

Status: Reviewed & tested by the community » Needs work

Something is not logic here... D5 and D6 are the same.

I checked the code inside _googleanalytics_track(). Now after we have changed the description "Define what user roles should be tracked by Google Analytics." the check boxes looks wrong.

I think this should looks like this in D5 and D6:

function _googleanalytics_track($account) {
  $track = FALSE;

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

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

  return $track;
}

This make sure:
1. if a role or user 1 is not checked, nothing get logged.
2. If a user is inside one checked role he get's logged.
3. if a user is in a role that shouldn't be logged, but in a second role that should be logged - he get's logged.
4. by default we do not log anything

hass’s picture

Ahh, no this don't work. I go to bed and think about this again later...

robloach’s picture

Status: Needs work » Reviewed & tested by the community

The patch I provided fixes the logic. It was the description that was deceiving, and was not reflecting the checkboxes correctly. The patch I provided fixed that. Checkboxes should default to off.

hass’s picture

Status: Reviewed & tested by the community » Needs work

@Rob: No, the patch is missing something. See the following. It tells is we should NOT track a role if the role should be tracked... that's wrong.

if (variable_get('googleanalytics_track_'. $role, FALSE)) {
       $track = FALSE;
}

I'm working on a new patch... wait some minutes.

hass’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
StatusFileSize
new1.61 KB

New D6 patch with cleaned up logic and documentation.

hass’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Status: Needs review » Patch (to be ported)

I have committed the patch in #17 to CVS after testing. Now we need to back port this patch to D5.

hass’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.61 KB

I leave this to budda to commit this into D5. Patch attached.

robloach’s picture

Status: Patch (to be ported) » Needs work

@Rob: No, the patch is missing something. See the following. It tells is we should NOT track a role if the role should be tracked... that's wrong.

if (variable_get('googleanalytics_track_'. $role, FALSE)) {
       $track = FALSE;
}

I'm working on a new patch... wait some minutes.

Exactly, that's the key here, because the description given to the user is:
'#description' => t('Define what user roles should not be tracked by Google Analytics.'),

... "should not be tracked". If you're going to reverse the logic here, you're going to also have to change that description.

hass’s picture

Status: Needs work » Needs review

@Rob: Latest code name the description t('Define what user roles should be tracked by Google Analytics.'),. The NOT is removed and therefor logic must change. Check out the latest D6 dev. All is changed and should now work like a charm.

hass’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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