paullb
paullb

Reputation: 4335

Tracking goals on AJAX calls in Google Analytics

On my website the goal that I want to track is actually attached to an AJAX call rather than a specific URL. Is there anyway to track that in Google Analytics?

Note: I am using JQuery.

The only solution that I can think of at the moment is having a tiny iFrame somewhere on the page and loading the Goal URL into that frame. However, that doesn't sound clean and it will also mess with my pageviews.

Upvotes: 1

Views: 2663

Answers (1)

Wally Lawless
Wally Lawless

Reputation: 7557

Have you taken a look at Google Analytics event tracking? I've used it before for AJAX based comments with some success.

On your page you would then use something similar to the following to track the URL in Google Analytics:

<input type='button' onClick="javascript:pageTracker._trackPageview('/goal/comment.html') />

Upvotes: 1

Related Questions