I am creating a form handling service that will allow users to copy and paste a form action and the service will store the data in a database and redirect to confirmation page on the users website.
What I’m trying to achieve:
I would like to include some analytics on the form such as, time taken to complete each field, form views, form activation etc. I’m guessing this would need some javascript also pasted on the users page that would link to an external script (on my site). But my question is, how would this work in practice?
I can’t use ajax as it would be on different domains and I also want as little code as possible to be copy and pasted by the user.
My question is not what specific code I need to use here, rather what approach do I take?
I’m thinking it will be similar to the google analytics snippet that they provide for tracking but im not 100% sure on how that works.
For cross-site requests, there is always the option of using script injection, as used with JSONP. For example, you could use jQuery.getJSON to pass some data as GET parameters to another site. Of course, only being able to do GET requests is a disadvantage. If you want/need to perform post requests, you could wrap your initial request in a web service, which basically converts GET parameters to POST parameters and forwards your request; YQL could do that for example.