Some of my google analytic events are not reflecting after 24 hours

Here is my code :

HTML part :

<div class="subscribe">
  <a href="#' title="library_membership">Subscribe for a Month</a>
  <a href="#' title="library_membership">Subscribe for a Year</a>
</div>

Javascript :

$js('div.subscribe a').live('click', function(e) {
    var This =  $(this);
    e.preventDefault();
    if(This.html().indexOf("Month") != -1)
        _gaq.push(["_trackEvent", "Subscriptions", "Clicked Month", This.attr( "title" )]);
    else 
        _gaq.push(["_trackEvent", "Subscriptions", "Clicked Year", This.attr( "title" )]);

});

I tried ga_debug.js to confirm if my events are pushed to google analytics and they are indeed showing up on the chrome console.

However, even after 24 hours, my clicks on "Subscribe for a Year" are not showing up on google analytics. My clicks on "Subscribe for a Month" have showed up. Can anyone help me why I am not getting the accurate data on google analytics.

Answers


Clean up your javascript/jquery and it should work:

$('div.subscribe a').live('click', function(e) {
    e.preventDefault();
    if ($(this).html().indexOf("Month") != -1) {
        alert("month");
    } else {
        alert("year");
    }

});​

Of course, replace the alerts with your GA code.

http://jsfiddle.net/8EJMK/

And, since live is deprecated, you can use on.

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

Depends on what version of jquery you are using:

$('div.subscribe a').on('click', function(e) {
    e.preventDefault();
    if ($(this).html().indexOf("Month") != -1) {
        alert("month");
    } else {
        alert("year");
    }

});​

http://jsfiddle.net/8EJMK/1/

You may also want to change this:

_gaq.push(["_trackEvent", "Subscriptions", "Clicked Month", This.attr( "title" )]);

To this:

_gaq.push(["_trackEvent", "Subscriptions", "Clicked Month", $(this).attr( "title" )]);

This isn't working. Should be $(this).


Need Your Help

How do I control the access of multiple threads to a collection of objects?

c# winforms multithreading locking propertygrid

I'm writing an application that displays a list of objects which the user can select and then view and edit the properties of through a PropertyGrid control. The object's properties are populated b...

How to login to HTML form using POST vars in C# (.NET)?

c# html logging forms post

For example, there is this website: www.azet.sk

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.