developer.leaddyno.com

JavaScript API Reference


Overview

This document details the LeadDyno JavaScript API. To load the JavaScript onto your page, place the following in the <head> section of your website:

 
<script type="text/javascript" src="https://static.leaddyno.com/js"></script>
 

After the script is loaded onto your page, you can access the global LeadDyno object. The following sections in this document describe all the properties and methods available to you.

 

Global Properties

LeadDyno.key (required)

Your public LeadDyno API key which can be found on your LeadDyno dashboard. This property must be set before you call any methods.

Example:

 
LeadDyno.key = '988d0a80f0880e0808bb30819721a74e9efb1b1a';
 
LeadDyno.domain

This sets the cookie domain for all the LeadDyno tracking cookies. By default we use the current domain of the page. If you have several sub-domains in which your site or application is hosted on, you can set this to the root domain.

Example:

 
LeadDyno.domain = 'example.com';
 
 

Methods

LeadDyno.recordVisit([callback])

Record a visit to your site.

  • callback (optional) - A callback function to be called after the visit is registered with the LeadDyno servers.

Example:

 
LeadDyno.recordVisit(function() {
    console.log("Visit successfully sent to LeadDyno");
});
 
LeadDyno.recordLead(email, [lead_data], [callback])

Record a lead that interacted with your site.

  • email - Email of new lead.
  • lead_data (optional) - An object with additional data to include with the new lead. Valid fields are:
    • first_name - First name of new lead.
    • last_name - Last name of new lead.
    • company - Company name of new lead.
    • address1 - Address line 1 of new lead.
    • address2 - Address line 2 of new lead.
    • city - City of new lead.
    • state - State of new lead.
    • zipcode - Zipcode of new lead.
    • country - Country of new lead.
    • phone - Phone number of new lead.
    • custom_status - A custom status for the new lead to be used in your application.
    • crm_* - Any field that is prefixed by crm_ can be included and will be passed along to the CRM integration, if enabled.
  • callback (optional) - A callback function to be called after the lead is registered with the LeadDyno servers.

Example:

 
LeadDyno.recordLead('johnd@example.com', {first_name: 'John', last_name: 'Doe'}, function() {
    console.log("Lead successfully sent to LeadDyno");
});
 
LeadDyno.recordPurchase([email], [options], [callback])

Record a purchase that occurred on your site.

  • email (optional) - Email of person making purchase.
  • options (optional) - An object with additional purchase options. Valid fields are:
    • purchase_code - Unique identifier for this purchase.
    • plan_code - Plan code - Assigns this purchase to the specified affiliate by overriding the detected affiliate in the initial visit, if there was one.
    • purchase_amount - Amount of purchase
    • commission_amount_override - Override the automatic commission calculation and specify a specific amount.
  • callback (optional) - A callback function to be called after the purchase is registered with the LeadDyno servers.

Example:

 
LeadDyno.recordPurchase('johnd@example.com', {purchase_code: '897123768512376237123987129387', plan_code: 'affiliate1', purchase_amount: '37.94'}, function() {
    console.log("Purchase successfully sent to LeadDyno");
});
 
LeadDyno.recordCancellation([email], [options], [callback])

Record a cancellation of a previous purchase.

  • email (optional) - Email of person to cancel.
  • options (optional) - An object with additional cancellation options. Valid fields are:
    • purchase_code - If cancelling a specific purchase, supply this field with a previous purchase code used in a recordPurchase call, otherwise all previous purchases for this person will be cancelled.
    • cancellation_code - If you want to supply a tracking ID for this cancellation, pass it in this field, otherwise LeadDyno will generate one.
  • callback (optional) - A callback function to be called after the cancellation is registered with the LeadDyno servers.

Example:

 
LeadDyno.recordCancellation('johnd@example.com', {purchase_code: '897123768512376237123987129387'}, function() {
    console.log("Cancellation successfully sent to LeadDyno");
});
 
LeadDyno.initPaypal()

Enable PayPal button integration. Any PayPal buttons on the page will be adjusted to contain new parameters that allow allow LeadDyno to receive events for those PayPal transactions.

Example:

 
LeadDyno.initPaypal();
 
 

Developer Tools

The LeadDyno library has integrated developer tools that make it easier to debug and troubleshoot the integration between the library and your application.

LeadDyno.devTools.setLogger(function)

Get access to internal LeadDyno logs for troubleshooting purposes.

Example:

 
LeadDyno.devTools.setLogger(function(message) {
    console.log("LeadDyno Log: " + message);
});
 
LeadDyno.devTools.reset()

Reset the state of the current visitor by removing all tracking and data cookies. Useful when developing and you don't want to wait for the 5 minute timer to expire for visit capture.

Example:

 
LeadDyno.devTools.reset();