The Web API for ActiveDEMAND

ActiveDEMAND API Support

If you are working on setting up an integration with our API, send an email to support@activedemand.com and we will give you access to our #activedemand-api slack channel where you can chat with our developers and have your questions answered.

Web API (ActiveDEMAND API Endpoint Reference)

https://developers.activedemand.com/

Javascript API (posting Web Forms using Javascript)

ActiveDEMAND has a javascript API that allows for posting to a web form using javascript. 

Step 1: create your form in ActiveDEMAND

Step 2: add the access javascript to the pages that have an existing form that you want to post data to ActiveDEMAND (see below)

Those form pages that have existing forms and the javascript below will post the form data to ActiveDEMAND whenever a form is submitted. Place this script anywhere after the default ActiveDEMAND tracking script is inserted. (note, this script requires the default tracking script included on the page)

 

<script type="text/javascript">
    var i = setInterval(function () {
        if (typeof AD !== 'undefined') {
            clearInterval(i);
            AD.ready(function () {
                AD.submit_ad_form(<ActiveDEMAND Form ID>, {
                    data: ["input-selecter-1", "input-selector-2", "input-selector-3"],
                    form_selector: "form-selector"
                });
            });
        }
    }, 300);
</script>

Examples:

Example 1: ID Referenced Inputs

Given this form:

<form accept-charset="UTF-8" action="/contact" class="contact-form" method="post">
 <input name="form_type" type="hidden" value="contact">
 <input name="utf8" type="hidden" value="?">

  <p>
  <label>
  Your Name:
  </label>
  <br>
  <input type="text" id="contactFormName" name="contact[name]" placeholder="John Doe">
  </p>
  <p>
  <label>
  Email:
  </label>
  <br>
  <input type="email" id="contactFormEmail" name="contact[email]" placeholder="john@example.com">
  </p>
  <p>
  <label>
  Phone Number:
  </label>
  <br>
  <input type="telephone" id="contactFormTelephone" name="contact[phone]" placeholder="555-555-1234">
  </p>
  <p>
  <label>
  Message:
  </label>
  <br>
  <textarea rows="15" cols="75" id="contactFormMessage" name="contact[body]" placeholder="Your Message"></textarea>
  </p>
  <p>
  <input type="submit" id="contactFormSubmit" value="Send" class="btn">
  </p>
</form>

This is the script you would put in:

<script type="text/javascript">
     var i = setInterval(function () {
         if (typeof AD !== 'undefined') {
             clearInterval(i);
             AD.submit_ad_form(12345, {
                 data: ["input#contactFormName", "input#contactFormEmail", "input#contactFormTelephone", "input#contactFormMessage"],
                 form_selector: "form.contact-form"
             });
         }
     }, 300);
 </script>

  Example 2: Name Referenced inputs

Given this form:

<form name="" action="/contact-us/#wpcf7-f190-p377-o1" method="post" class="wpcf7-form" novalidate="novalidate">
<p>Name <input type="text" name="your-name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false"></p>
<p>Email<input type="email" name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" aria-required="true" aria-invalid="false"></p>
<p>Phone Number <input type="tel" name="phone" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-tel wpcf7-validates-as-tel" aria-invalid="false"></p>
<p>Company <input type="text" name="company" value="" size="40" class="wpcf7-form-control wpcf7-text" aria-invalid="false"></p>
<p><textarea name="Comments" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea" aria-invalid="false" placeholder="COMMENTS"></textarea></p>
<p><input type="submit" value="Send" class="wpcf7-form-control wpcf7-submit"><img class="ajax-loader" src="http://podmarketinginc.com/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Sending ..." style="visibility: hidden;"></p>
<div class="wpcf7-response-output wpcf7-display-none"></div></form> 

This is your code  

<script type="text/javascript">
     var i = setInterval(function () {
         if (typeof AD !== 'undefined') {
             clearInterval(i);
             AD.ready(function () {
                 AD.submit_ad_form(12345, {
                     data: ["input#contactFormName", "input#contactFormEmail", "input#contactFormTelephone", "input#contactFormMessage"],
                     form_selector: "form.contact-form"
                 });
             });
         }
     }, 300);
 </script>

You can also use this script to post the data to ActiveDEMAND immediately (as opposed to when the form submits).  You would use this when you have the raw data that needs to be submitted and want to submit it during some other point in the user flow.

<script type="text/javascript">
     var i = setInterval(function () {
         if (typeof AD !== 'undefined') {
             clearInterval(i);
             AD.ready(function () {
                 AD.submit_ad_form(1234, {data: ["Test Person", "test.person@test.com", "1112221212", "Test Company", "Some extra comments"]});
             });
         }
     }, 300);
 </script>

 

Updating Contact details via the Javascript API

ActiveDEMAND has a javascript api that allows for updating a contact's details.  You would use this in the situation where you know who the contact is, and want to update that information in ActiveDEMAND.

You would use the following javascript to post the available data to ActiveDEMAND.  All fields are optional, any data you send will be updated on the current contact who is visiting the page this script runs on.

<script type="text/javascript">
    var data = {
        email_address: 'j.test@test.com',
        first_name: 'Jane',
        last_name: 'Test',
        full_name: 'Jane Test',
        title: 'CEO',
        employer: 'Test Company Inc',
        phone: '1112221212'
    }
    AD.update_contact(data);
</script>
Was this article helpful?
0 out of 1 found this helpful

Comments

0 comments

Please sign in to leave a comment.