Tuesday’s Tip: Auto-apply a Promo Code in Infusionsoft

Infusionsoft® gives you the ability to offer promo codes to your customers. To make it easier on your customers and to simplify the checkout process, you can add a snippet of JavaScript to your order form to automatically apply a promo code.

To use this JavaScript, replace YOUR-PROMO-CODE with the promo code you want to be applied. Add this JavaScript to the Custom Header HTML area for your order form:

<script type="text/javascript">
// <![CDATA[
jQuery( document ).ready(function() {
    jQuery('#promoCode').val("YOUR-PROMO-CODE");
    jQuery('a.codeButton')[0].click();
});
// ]]>
</script>

When your customers open the order form, the promo code will be applied automatically as soon as the page finishes loading.

4 Comments

  1. jQuery to save the day! While there is nothing wrong with this code, I generally prefer:

    jQuery(‘a.codeButton:first’).click();
    versus
    jQuery(‘a.codeButton’)[0].click();

    It’s 6 and 1/2.

    Reply
    • Thanks for the input! As you said, it is a matter of preference; both options give the same results.

      We chose to go with [0] for performance reasons. Using :first is slower than using [0] (see: http://jsperf.com/jquery-first-vs-first-vs-eq-0-vs-0/9), although I doubt it would make a noticeable difference to the customer in this situation.

      Reply
      • Yes indeed it is speedier. I as well doubt it wouldn’t be a noticeable difference in speed but who knows, there might be someone out there on a “jitter bug” and they need every CPU cycle they can get!

Leave a Reply