Skip to main content

Bug Tracker

Side navigation

#3712 closed bug (invalid)

Opened December 12, 2008 10:32PM UTC

Closed June 05, 2009 02:04AM UTC

Google Analytics breaks jQuery.

Reported by: simshaun Owned by: flesler
Priority: major Milestone: 1.3
Component: unfiled Version: 1.2.6
Keywords: Cc: simshaun
Blocked by: Blocking:
Description

I'm not sure whether to post this here or at Google, but here's the problem.

I have a page where I am using jQuery's load function to inject HTML into a div container.

Right underneath the opening body tag, I've written a script to bind an onClick event to all A tags. Upon click, it fires e.preventDefault(), reads the href attribute and loads that page into a div container.

At the bottom of the page, I've placed Google Analytics tracking code.

In FireFox, I've found that Google Analytics takes precedence over the onClick event that jQuery binded to the link. Instead of loading the link's target into the div container, FireFox actually tries to load the link as if I never used e.preventDefault().

IE seems to work OK though, (or handles it inappropriately and seems to work fine.)

I believe that this issue is solved by placing Google Analytics in the head tag, or at the very least, before my jQuery code. The problem is that my client has some wacky SEO company who won't let move the Analytics code.

Therefore, is it possible to fix this and is this an issue on jQuery's side, or Google Analytics?

Attachments (0)
Change History (4)

Changed December 12, 2008 10:36PM UTC by simshaun comment:1

It's possible I just typed all of that for nothing.

The pages that are injected into the DIV container have the Google Analytics code as well. Once I removed the Analytics code from those pages, everything works fine.

So now I ask, is this still a bug?

Why does having Google Analytics on the pages called via the load function cause the page to break?

Changed December 15, 2008 11:06PM UTC by flesler comment:2

cc: → simshaun
resolution: → fixed
status: newclosed

You'd rather ask this on jQuery's google group.

Changed June 04, 2009 10:12PM UTC by traiann comment:3

resolution: fixed
status: closedreopened

the same problem here. I have a jquery script which works fine until I activate the google analytics code on the pages. Is there any fix to this?

Changed June 05, 2009 02:04AM UTC by dmethvin comment:4

resolution: → invalid
status: reopenedclosed

Same answer though. This is a bug tracker and the question you're asking is best answered on a forum.