Skip to main content
Act-On Software

Using a Code Snippet to Auto-submit a Form

AUDIENCE: Administrators, Marketing Users, Web Developers
OBJECTIVES: 

  • Define the process for forcing Act-On forms to auto-submit
  • Define possible use cases for this functionality
You can set a form to submit automatically when a visitor loads the page.

If you are looking for a double opt-in process with forms, see this page instead.

Lab forms

Pasted below is a JavaScript snippet you can place on an Act-On landing page with an embedded Act-On form to enable the auto-submit function. It will hide the form, so that it is invisible to the person clicking through.

<script>
aoPostLoadCallback = function(){ document.querySelector(".ao-form-submit").click(); document.querySelector(".ao-form").style.display = "none"; }
</script>

 This can be pasted into the JavaScript settings section of the Act-On Landing Page

Screenshot_101917_110757_AM.jpg

Classic Forms

Pasted below is a JavaScript/jQuery snippet you can place on Classic Forms to cause them to auto-submit when the form loads.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
jQuery.noConflict();
jQuery(document).ready(function ( $ ) {
   $("input[name='Submit']").click();
});
</script>

 This can be pasted into the External Web Analytics Support text area in the Settings step of the form editor, or within a custom stationery. Please note that this script would also work on many non-Act-On forms, and other similar alternative scripts may work with Act-On-built forms as well.

Possible use cases for an auto-submit form

If a known visitor (someone who previously submitted a form or who has clicked a link in an Act-On-tracked email) opens a form, you can pull any previously-known system-fields for this person and write that data to a hidden field. For example, the following form would submit the following fields for previously-known submitters but not display any of the fields being collected: