Search code examples
jqueryjquery-mobilegoogle-analyticsgoogle-analytics-api

Google analytics conflicting with JQuery code


I am having an issue where Google analytics is conflicting with my code. The system I am working on loads Google analytics as the first script. This cant be changed, so i need to find a way out of this conflict without re-ordering the scripts.

The code is here. http://jsfiddle.net/2j6Zd/

When removing

    $("#slide-right").pageSlide({
        width: "210px",
        direction: "right"
    });

It works. So somehow I need to call this differently or soemthing else.

Anyone able to help please?


Solution

  • I have the solution. It was line $("body").contents().wrapAll(psBodyWrap);

    This was wrapping the _gaq snippet inside as well. So it was firing twice.

    The solution was.

    $("body").contents().not("footer").wrapAll(psBodyWrap);.

    The _gaq snippet was located in the footer. So excluding it from the wrap allowed everything to execute correctly. This points to it being directly related to google analytics code. It might not have been a code conflict, but a conflict none the less.