Trouble tracking AJAX requests

I am a little confused on how to go about tracking ajax requests with Piwik. I am using jQuery to ajax in content from other content pages I have in a /pages directory onto my main index page. I found a post on piwik-hackers about someone trying to do this with the old javascript tracking code. He claimed he got it to work by including the piwik tracking code in the html that was ajaxed in. When I try this however, my page gets stuck loading and eventually firebug gives me a “too much recursion” error.

Lately I have been trying to execute trackPageView function within the ajax function I use to call the content pages, but have only been successful in recording pageviews for the index page, and not the content page which was ajaxed. There seems to be a lack of documentation on tracking ajax requests, so I am at a loss.

Has anyone successfully implemented the tracking of ajax requests with piwik, and if so, how did you pull it off?

Still no headway. No one else has had any luck?

What’s wrong with calling trackLink()?

the alternative is the server side tracking api. an alpha version is in trac.

[quote=vipsoft @ Sep 16 2009, 04:46 PM]What’s wrong with calling trackLink()?

the alternative is the server side tracking api. an alpha version is in trac.[/quote]

Thanks for the tip, I was able to get my requests tracked with trackLink().

I’ve tried to use trackLink() to log ajax calls but (correct me if I’m wrong) I have only the choice between ‘link’ and 'download" as linkType.
I would prefer to log these calls as standard “page views” with a specific url (instead of the regular document’s url). Is there a trick to do that ?

Use setDocumentTitle, setCustomUrl, and trackPageView.

That’s what I need. Thanks !

Make sure you put your trackLink() and other Piwik JS requests within a try/catch in case the user actively blocks Piwik (eg with AdBlock).