On line 99 of googleanalytics.module, the check that $user->uid >0 prevents creating a segment for anonymous users.

removing that test allows the pageTracker var to send that role to google analytics.

Comments

hass’s picture

Category: bug » support
Status: Active » Fixed

Anonymous user do not have profile fields. Segmentation without profile data sounds pretty useless.

Status: Fixed » Closed (fixed)

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

mcurry’s picture

First, let me say thanks to the maintainers for this very useful module.

I would like to suggest that the module *should* allow segmentation tracking of anonymous users, even though they cannot have profile fields.

The admin UI allows me to select tracking for 'anonymous users'. When combined with the 'Add segmentation information to tracking code->User roles' selection, this leads me to expect that I would see 'anonymous user' tracking in my Analytics reports (in the 'Visitors->User Defined' reports). It did lead me to expect it, I tried it, it didn't work as expected, so here I am, looking at an old support request for this issue.

Why would I want to track 'anonymous' role members, separately from other roles?

Well, it's useful to see how many anonymous users are on the site, how long they stay, etc. compared with other user roles (contributors, subscribers, etc) without doing mental arithmetic.

I am not using any profile fields in my Analytics reports, I just want to analyze traffic for anonymous vs. other user roles.

Setting a user-defined variable for anonymous visitors (by removing the test for $user->uid >0, as described in the original post) does indeed provide the expected results -- the page content includes pageTracker._setVar("anonymous user") in the Analytics page script, and my Analytics reports now show the expected traffic for the anonymous user roles.

My opinion is that it's useful to some people, even if anonymous users don't have profile fields.

In any case, if the analytics module doesn't allow segmentation tracking for anonymous user roles, perhaps the module settings page should mention that. Such a note might help prevent confusion and spurious support requests.

bright8’s picture

Version: 6.x-2.2 » 6.x-3.0
Category: support » feature
Status: Closed (fixed) » Active

I'd like to add my voice of support for this too - I agree with comment #3.

I just spent ages trying to figure out why my GA segmentation report always showed 0 for anonymous users, then discovered that's because the User Variable isn't set at all for those users. Like the previous poster, I too want to be able to segment GA reports by the type of user: anonymous, registered users (authenticated), etc. Although I do use user profile fields, I don't currently need to segment by geography or other profile parameters.

Like the previous poster, I was mislead by the GA module UI. If I choose User Roles under "User segmentation settings" I assumed (naturally, I think) that those roles would reflect the values I had selected under "Role specific tracking settings". However, I saw in issue #916314: Segmentation requires Custom variables update that Google has deprecated _setVar so this may all be academic. The use of a token to represent each role to be tracked/segmented (including Anonymous) makes sense to me.

The fact that when tracking for Authenticated users is checked (under Role specific tracking settings), all other authenticated roles are tracked (and added to the user variable), irrespective of whether they are checked or not, just added to my confusion around this. Irrespective of whether the issue can or will be addressed, I would strongly urge the addition of a few words to the UI for Roles and Segmentation to explain how it works - that would save new users of the module from wasting a lot of time figuring out that it doesn't work the way many (most?) people would expect.

Everything else works brilliantly though, so many thanks to all for their hard work on this module!!

hass’s picture

Status: Active » Fixed

I have never seen an use case and forgotton about the user groups. Removed $user->uid > 0 as I have no idea why budda have added this. Committed half tested patch.

mcurry’s picture

@hass:

Thanks for the super-fast response and CVS commit.

I'll try out the new build as soon as I can.

Status: Fixed » Closed (fixed)

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