I have some nice ajax contact/enquiry forms etc on a website I'm working on which are working great (and degrade gracefully).

I'd like to make use of Google Analytic's 'Goals' feature. The trouble is, the only way I can see this could work for my form is if it redirected to another page (be it a thank-you page or similar) after submission, then I can enter that url at a page people only visit after they've submitted my form. I can see how this would work for my non-JS visitors (if any even have it disabled!), but is there any way to track when an AJAX form has been submitted?


Edit: I should add that I know I can work out manually the conversion rate and so on/so forth by the number of enquiries I receive, but why not try and make things easier for mysef? :-)


You could use Google Analytics' functionality to log a pageview for non-existent page URL when your form is submitted. This fake URL can then be used in your goal.

The code for logging a fake pageview is as follows:

_gaq.push(['_trackPageview', '/fake/page/url'])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.