Sorry if this is a really dumb question.

Just upgraded the module for Drupal 5.14 installation on http://www.toodlepip.co.uk - all the code looks like its properly enclosed and the upgrade proceeded without any errors. The release notes state that outgoing links are being tracked through Event Tracking on GA, but nothing is showing up in the results. It's been running for a few days and I'd expect some activity.

Any thoughts on what might be wrong here? Thanks in advance.

CommentFileSizeAuthor
#19 googleanalytics.js.txt2.42 KBhass
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Status: Active » Closed (duplicate)
toodlepip’s picture

Thanks for the reply. The events graph is showing up in the GA account, it's the actual stats. GA is showing 0 events. I have the GA drupal module installed on two different Drupal sites (http://www.chinwag.com and http://www.toodlepip.co.uk) but neither are registering any events. Could it be a Jquery clash?

Thanks for your help, much appreciated.

toodlepip’s picture

Status: Closed (duplicate) » Active
hass’s picture

Status: Active » Fixed

Make sure you have downloads, email and/or outgoing links tracking enabled. Aside it may take some time after the first event is recorded and until it's shown in the reports... I cannot say how long this might take... try to wait up to 2 weeks.

hass’s picture

Hm... checked your http://www.toodlepip.co.uk site and code is correct... all should work, but I also don't see the Event is firing the tracking out to google if a external link is clicked... I have not tested this with jquery_update... but I'm not aware about jquery functions that have changed. Are you able to test with standard jquery? Could you try to add some console.log() lines to the googleanalytics.js and debug if it jumps in the correct if statement?

hass’s picture

Status: Fixed » Postponed (maintainer needs more info)
toodlepip’s picture

Hiya hass,

Thanks for the feedback. I've tried adding a few console.log() lines to debug the googleanalytics.js file. It looks like the jquery function to bind the clicks isn't working properly with the new version of jquery. Changing:

$('a', context).click( function() {

to

$('a').click( function() {

seems to do the trick. My Javascript skills aren't so hot, so not sure whether the context field is actually used. Could you advise? I'll try running without the version of the click() function above for a day or so and see if the clicks are tracked properly.

Thanks for your help, any feedback on the above would be ace, thanks.

hass’s picture

Ok, this is good and helpful information.

I need to investigate why this break things, but you can keep it as is now as an interims solution until we found the source of this issue and a fix. No functional problem at all - the context is not really used yet.

hass’s picture

Category: support » bug
hass’s picture

Title: Event tracking not registering on GA » Selector $('a', context) is broken with jquery_update
Project: Google Analytics » jQuery Update
Version: 5.x-1.7 » 6.x-1.x-dev

I'm moving this to jquery_update for now. Maybe someone from there can help us quickly or at least give a hint what could be broken and how to fix if not a bug in jquery_update.

hass’s picture

Version: 6.x-1.x-dev » 5.x-2.x-dev
hass’s picture

Status: Postponed (maintainer needs more info) » Active
hass’s picture

Priority: Normal » Critical
hanoii’s picture

I just got to this issue after experiencing this behavior. One strange thing is that I have several drupal sites, all with jquery_update and the latest jquery and all of them are working except one, this one.

Now I am not sure the bug goes through jquery_update, can you explain me what context is and how that should be used?

What I can tell is that in the site not working the line:

context = context || document;

Is returning context and then it's not working. If I make that to be just

context = document;

It starts working, which is the same as doing

$('a').click( function() {

as explained in #7,

but if context is not used, and it's making problems, isn't it better to remove it from the google analytics code?

a.=

hanoii’s picture

I have just checked the sites that are working and they have an older version of the GA code without the context whatsoever, just as #7. What is this? and is it correctly used?

hass’s picture

D6 have added context = context || document; in drupal.js.

Drupal.attachBehaviors = function(context) {
  context = context || document;
  if (Drupal.jsEnabled) {
    // Execute all of them.
    jQuery.each(Drupal.behaviors, function() {
      this(context);
    });
  }
};

I've backported this logic to D5 to make the code easier to maintain. See #330616: Allow re-binding click events with AHAH/AJAX why context have been added. I wonder why it is not working on one of your sites, but the others... very strange...

hass’s picture

Could one of you with the jquery_update installed give this code change together with $('a', context).click( function() { a try?

[googleanalytics.js]

if (Drupal.jsEnabled) {
-  $(document).ready(gaTrackerAttach);
+  $(document).ready(function() {
+    Drupal.gaTrackerAttach(null);
+  });
}
ianchan’s picture

subscribe

hass’s picture

Project: jQuery Update » Google Analytics
Version: 5.x-2.x-dev » 5.x-1.x-dev
Status: Active » Needs review
FileSize
2.42 KB

Above code in #17 has a bug. Please give this new code a try. I think it should work now.

[googleanalytics.js]

if (Drupal.jsEnabled) {
  $(document).ready(function() {
    Drupal.gaTrackerAttach(this);
  });
}
hass’s picture

Title: Selector $('a', context) is broken with jquery_update » Selector $('a', context) is is not logging clicks with jquery_update
Status: Needs review » Fixed

I tested the changes above on my live site with original jquery and jquery_update and clicks on outgoing links are working for me. I've committed the code to CVS, but I would be happy to get some feedback from you guys if it would also work for you before rolling a new release.

It's very simple to test if you create links with target _blank as it would help you to see that the executed GA request is shown in Firebug pane on the page where you clicked the link. Otherwise you need Firebug history add-on or Fiddler to see the request.

hass’s picture

Title: Selector $('a', context) is is not logging clicks with jquery_update » Faulty Drupal.gaTrackerAttach init prevents click tracking (with jquery_update only)

Status: Fixed » Closed (fixed)

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

aiphes’s picture

Status: Closed (fixed) » Needs review

i open an issue : http://drupal.org/node/846344 for the 6.x version

aiphes’s picture

Status: Needs review » Closed (fixed)