I’m trying to track how often a Poll content type is answered as a block in Drupal when it’s embedded on a number of pages as a block. For example, if 5 users answer the poll on page A, and six users answer on page B, I need to know those breakdowns, but not their specific answers.
I’d planned to simply look in Google Analytics for the number of times users had taken the path from Page A -> Poll Page, but answering the Poll actually leaves the user on the same page, so I’m stumped how to do it. Any suggestions?
For performance, using google analytics is not a bad idea. You can attach a JavaScript event to the submit button of the form, and send the info to GA, about the poll, before the form submits.
An alternative solution, would be to track it in Drupal. Here you could add a submit handler to the form, and save the url it was posted from. You would need to add the submit handler with
hook_form_alterJavaScript is not that hard, you got jQuery loaded, so something like this should do.
Look up the GA api for what you need to do, it depends on which version you use.