Trouble tracking AJAX requests

Posted by jjhudson 

Advanced
jjhudson [ # ]
September 08, 2009 06:47PM
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?
jjhudson [ # ]
September 16, 2009 04:15PM
Still no headway. No one else has had any luck?
vipsoft [ # ]
September 16, 2009 06:46PM
What's wrong with calling trackLink()?

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



Buy me a beer. Show me some love.

Changes in the upcoming release: CHANGES
jjhudson [ # ]
September 17, 2009 07:17PM
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.

Thanks for the tip, I was able to get my requests tracked with trackLink().
andras [ # ]
February 04, 2010 06:56PM
Quote
vipsoft @ Sep 16 2009, 04:46 PM
What's wrong with calling 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 ?
vipsoft [ # ]
February 04, 2010 07:18PM
Use setDocumentTitle, setCustomUrl, and trackPageView.



Buy me a beer. Show me some love.

Changes in the upcoming release: CHANGES
andras [ # ]
February 05, 2010 10:27AM
Quote
vipsoft @ Feb 4 2010, 06:18 PM
Use setDocumentTitle, setCustomUrl, and trackPageView.
That's what I need. Thanks !
DriverDan [ # ]
February 09, 2010 03:06PM
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).
Sorry, only registered users may post in this forum.

Click here to login

Free Forum support is provided by the Piwik Community. If you require any urgent or professional help, contact Piwik Professional Services team!