How to track location of a sign-up form in a block? I have a newsletter sign-up form in a block that appears on many pages. When the form is submitted, I want to capture the current page.

The block and form are created in code. In the submit function, I am using drupal_get_path_alias() to get the current location. The block has no explicit caching set, so I believe DRUPAL_CACHE_PER_ROLE is assumed.

I had been thinking that although the block is cached for anonymous users, the submit function would still retrieve the correct location.

However, it doesn't seem to be working correctly. I always get a value for the path, but I believe it's incorrect in many cases.

What should I do to make sure I get a correct path on submit?

Update Mar 17 2014: I switched caching from the assumed DRUPAL_CACHE_PER_ROLE to DRUPAL_CACHE_PER_PAGE and that seems to have resolved the problem. Also, for the record, the problem looked like this: most sign-ups come from one page. But every once in a while a sign up will come from a different more obscure location on the site. What I was seeing was that "other location" repeated for the next x of signups (the number varied). So, in that respect, it did look like a caching problem.
have you fully tested your guess?  what you've described should work, AFAIK.

other options would include:

1) modifying the form to have a hidden value, set using drupal_get_path_alias() ...  it would set the value on load, rather than looking it up on submit.

2) a google analytics event tracker attached to the submit button the form.