jonners99
jonners99

Reputation: 134

Google analytics track jquery open

We are relaunching our company website and want to move away from inhouse analytics which are clunky and wasteful and better use our google analytics.

We have a page where we list job ads, clicking on a job title opens the job description below the title. At present we use php to track these opens and then feed each click into our database.

How can we do the same with google analytics?

Our current code is fairly standard:

$('document').ready(function(){
  $('#linkbox').hide();
  $('span.linka').toggle(function() {
    var id = $(this).attr('id');
    $('#linkbox' + id).show(500);
    $.post('clickrecorder.php', {"productID": encodeURIComponent(id)} );
  }, function() {
    var id = $(this).attr('id');
    $('#linkbox' + id).hide(500);
  });
});

Clickrecorder.php literally increments the number in the database by one.

Upvotes: 0

Views: 206

Answers (1)

mike
mike

Reputation: 7177

You can track the ad view as a Google Analytics Event with the following:

_gaq.push(['_trackEvent', 'job ad', 'view', id]);

See Event Tracking Guide for more details about Events.

Upvotes: 1

Related Questions