Bug Tracker

Opened 11 years ago

Closed 11 years ago

#3712 closed bug (invalid)

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?

Change History (4)

comment:1 Changed 11 years ago by simshaun

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?

comment:2 Changed 11 years ago by flesler

Cc: simshaun added
Resolution: fixed
Status: newclosed

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

comment:3 Changed 11 years ago by traiann

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?

comment:4 Changed 11 years ago by dmethvin

Resolution: invalid
Status: reopenedclosed

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

Note: See TracTickets for help on using tickets.