How do you add a library to page attachments (or perform any other alteration) only AFTER form submission?
Long explanation:
I have a very simple contact form which redirects to the frontpage after submission and displays a "Thank you" message.
I need to trigger custom JS events for Google AdWords integration after form submission. In theory this is very simple, just implement hook_page_bottom
and attach library with custom JS code.
However, this library should only be attached after form submission and I can't figure out how to detect whether a page load comes from a form submission. My first attempt was to implement hook_form_alter
and add a custom submit handler. However, this submit handler is only fired right after form submission, but not in the next page load, which means that my library doesn't get attached.
What is the Drupal way of this?