Using JavaScript to Auto-Submit Act-On Forms

  • Updated

You can quickly and easily set Act-On's Forms to auto-submit by adding a snippet of JavaScript. Use auto-submit for hidden Forms on your Act-On Landing Pages to capture a variety of user information, including double opt-ins, NPS feedback, event confirmation, and more.

Instructions

Add JavaScript to a Landing Page

You cannot add JavaScript directly to an Act-On Form. Instead, you'll need to add any code to the Landing Page that hosts your Form. Once you've designed your Form and embedded it on a Landing Page, follow these steps to enable auto-submit:

  1. Go to Content > Landing Pages.

  2. Find the Landing Page hosting your Form, hover over it and   Edit to open the Landing Page composer.

  3. Go to the Design tab.

  4. In the right-hand Settings panel, click Edit JavaScript:

    Add_JavaScript.png

  5. Paste the following code snippet into the Edit JavaScript field:
    <script>
    aoPostLoadCallback = function(){ document.querySelector(".ao-form-submit").click(); document.querySelector(".ao-form").style.display = "none"; }
    </script>
  6. Click OK.

  7. Save the Landing Page.

Is your form hosted on your website? This JavaScript is intended to work with Act-On Landing pages. If you are hosting your form on your own web page, you may need a developer to assist with applying this code to your website.

 

Add JavaScript to Classic Forms

You can add JavaScript/jQuery directly to Act-On's Classic Forms. Follow the steps below to enable your Classic Form to auto-submit when the Form loads:

  1. Go to Content > Forms.
  2. Create a new Classic Form or Edit an existing Classic Form.
  3. Go to the Settings tab.
  4. Scroll down to the External Web Analytics Support field and paste the following code snippet: 
    <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>
  5. Click Next at the top of the screen.
  6. Save the Classic Form.
Tip! You can also add this snippet to custom stationery or an external page. However, Act-On cannot support custom code. Please work with your web developer if you would like to apply the above code in custom stationery or on an external page.

Was this article helpful?

Have more questions? Submit a request