I have installed the newest dev version of the GA module so we can take advantage of the new GA code. Sadly though one bug which has reared it's head is some inconsistancy with the 'outgoing links' tracking. I am getting lots of click events coming through to GA (possibly caused be javascript click events which return false), and when I select 'click' in the analytics UI it tells me 'There is no data for this view'.

I couldn't find a similar bug in the issue log, is it just me seeing this issue? Any help would be gratefully received.

Thankyou,
Dan

CommentFileSizeAuthor
#9 googleanalytics.js_.patch611 bytesretrodans
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

retrodans’s picture

It appears there is a problem with:
$(document.body).click(function(event) {

I put an alert in, and when an outgoing link is clicked, the function above isn't run, it does work alright with:
$('a').click(function(event) {

retrodans’s picture

Category: bug » support

Further testing appears to show that it's to do with javascript on our end controlling whether a new tab is opened or not using a class. This is done so that users can disable the new tab system, giving them control back over their browser. Is there a way around this, or is it something we will have to consider in our development?

Note: Have changed category to 'support request' as have found what is causing the issue

hass’s picture

Status: Active » Postponed (maintainer needs more info)

Can you provide an live url and detailed step by step instruction how to repro, please?

I remember someone else had the same type of problem, but was unable to repro nor had an idea what the real source of this clicks was. Would be great to understand and solve it.

retrodans’s picture

Status: Postponed (maintainer needs more info) » Active

I'm afraid the site we are experiencing these issues with is currently in development, so the url is locked down. But as for a step by step guide:

1. Install newest dev version of GA module (uses asynchronous browsing)
2. Setup listener to handle click events for external links

$('a.link_external').click(function(){
    window.open(this.href);
    return false;
});

3. Setup jquery.tools scrollable effect

It's the line 'return false;' which is causing the outgoing link. I will just remove this line, and it would then work and start tracking the outgoing links.

BUT this isn't going to solve the random 'click' events appearing without any href data. The href data does seem to get sent across, so will see how it all changes with the 'return false' removed, and will update on whether this alone solves the issue.

hass’s picture

Do you know that the ga module already have an external links click event listener or is this only an example?

retrodans’s picture

The example was to purely open a new tab in the browser, not to handle GA. I could use the function in the module and amend it, but would rather not modify the modules code if possible.

hass’s picture

Status: Active » Postponed (maintainer needs more info)

I need an example code snippet for a repro case - not any unrelated code. I have no idea what I should do with above code example, as it does not represent a link example that coud theoretically be broken nor any special case.

retrodans’s picture

Sorry for the late response to your message, I am not getting notifications when people post responses. I went into the module and did some alerts within the modules js

else if (ga.trackOutgoing) {
        alert("outgoing");
        alert(this.href);
          // External link clicked.
          _gaq.push(["_trackEvent", "Outgoing links", "Click", this.href]);
}

This showed me that when an attribute similar to below is clicked, the alert gets called:

<a name="test">test</a>

So what I think would fix the issue is to amend the if statement to the below, this will make sure the click event is actually going to go somewhere before tracking it.

else if (ga.trackOutgoing && this.href) {
          // External link clicked.
          _gaq.push(["_trackEvent", "Outgoing links", "Click", this.href]);
}

What are your thoughts on this? I may need to use this on our site, so I could setup a patch if you think it is of use.

Thankyou,
Dan

retrodans’s picture

FileSize
611 bytes

I created a patch (my first so far). Hope this helps someone, if there are issues with what I have done, please do let me know, I will try to check back here when I can.

hass’s picture

Category: support » bug
Status: Postponed (maintainer needs more info) » Needs review
hass’s picture

Status: Needs review » Fixed

Committed your fix to all branches.

Status: Fixed » Closed (fixed)

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