We're using the profiling stuff in Google Analytics to set a custom user defined attribute and it wasn't working for us. I looked through the help and didn't find what I was looking for (the answers stuff is really disorganized). Anyway, I contacting Analytics support and the reply I got back pointed out this:

http://www.google.com/support/googleanalytics/bin/answer.py?answer=57045

"To set a visitor segment, simply call the JavaScript __utmSetVar function. For example, make the following call anywhere on the web page below your tracking code:"

However, the Google Analytics module places the segmentation code before urchinTracker() is called, which is the opposite order. Given the way __utmSetVar works, I could see this still being successful some of the time. Yet, we aren't getting any of are segmentation hits to come through.

I've attached a patch which places segmentation after the urchinTracker() call. I haven't yet tested to see if this actually fixes the problem, but I will report back if the stats start showing our segments after I apply it to our production site (hopefully I will respond by tomorrow).

CommentFileSizeAuthor
segmentation-reorder.patch829 byteszostay
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

budda’s picture

The site the segmentation module was original developed for (https://www.forum4e.com/) is working fine using the current javaScript code.

Google Analytics is reporting the segmentation data fine for nearly a year now, so not sure how it can be wrong?

zostay’s picture

Well, according to the documentation, calls to __utmSetVar should happen after calling urchinTracker. By moving segmentation after the call to urchinTracker, my statistics are now being collected correctly.

As I mentioned, because of the way the way this is implemented, it's quite possible that you'd be getting results in some circumstances anyway. It would mostly depend on what other JavaScript you have running on the page if the loading of the tracking image ended up being loaded after urchinTracker anyway.

Anyway, this definitely fixed my segmentation problems immediately.

budda’s picture

Status: Needs review » Fixed

Change applied to CVS.

Anonymous’s picture

Status: Fixed » Closed (fixed)