JavaScript Functions
AuroraLeadCaptureAsyncInit
Lead Capture AI can also be configured through the AuroraLeadCapture
namespace. In order to use these functions, they must be called from within this function.
window.AuroraLeadCaptureAsyncInit = () => {
// Use AuroraLeadCapture within this function
};
AuroraLeadCapture
addEventListener
Provide a callback function that will be called based on the event sent by Lead Capture AI. Allows multiple event listeners on the same event via multiple calls.
Usage
AuroraLeadCapture.addEventListener(event, callback);
Parameters
parameter | type | note |
---|---|---|
event (required) | string | Detailed below in Event Types |
callback (required) | function | Function to be called when the specified event occurs |
Returns
Void
Event Types
Passthrough Attributes
The Lead Capture SDK will pass through common marketing URL parameters from the host page via JavaScript events. This is intended to enable campaign attribution tracking when leads are converted through Lead Capture AI. The parameters are sent in the referrerParams
property on all JavaScript events.
The referrerParams
property is an object that may contain any of the following properties:
name | type | Matching URL Parameter |
---|---|---|
utmSource | string | utm_source |
utmMedium | string | utm_medium |
utmCampaign | string | utm_campaign |
utmTerm | string | utm_term |
utmContent | string | utm_content |
fbclid | string | fbclid |
gclid | string | gclid |
A property will only be present if it was on the host page where Lead Capture AI ran.
contact
Use this to get lead contact information from Lead Capture AI. This event will be sent when:
- Contact information is submitted
This will only be sent a single time and does not contain any solar model data.
const contactCallback = (contact) => {
console.log(contact);
};
AuroraLeadCapture.addEventListener('contact', contactCallback);
The contact
object will contain the following properties:
name | type | note |
---|---|---|
address | string | Full address, standardized according to google |
averageMonthlyBill | number | What the user entered as their average monthly bill in dollars |
city | string | City of the address |
country | string | Country of the address |
string | Email entered by the user | |
firstName | string | First name entered by the user |
lastName | string | Last name entered by the user |
latitude | number | Latitude of the address |
longitude | number | Longitude of the address |
orgId | string | Organization ID |
phone | string | Phone number entered by the user |
postalCode | string | Postal code of the address |
projectId | string | ID of the project |
referrerParams | object | See Passthrough Attributes for additional information |
state | string | State of the address |
street | string | Street of the address |
streetNumber | string | Street number of the address |
lead
Use this to get lead contact information and solar model data together from Lead Capture AI. This event will be sent when:
- Contact information is submitted
- Results page is displayed (if contact information has previously been submitted)
- Error page is displayed (if contact information has previously been submitted)
This will be sent multiple times and should be used by searching for a record to update based on the projectId
and creating a new record if one is not found. Be sure to account for these multiple events in your application or integration logic.
const leadCallback = (lead) => {
console.log(lead);
};
AuroraLeadCapture.addEventListener('lead', leadCallback);
The lead
object will contain the following properties:
name | type | note |
---|---|---|
address | string | Full address, standardized according to google |
annualProduction | number | Total kWh produced in a year(1,2) |
averageMonthlyBill | number | What the user entered as their average monthly bill in dollars |
city | string | City of the address |
country | string | Country of the address |
string | Email entered by the user | |
error | boolean | true if Lead Capture fails to generate a solar model(2) |
firstName | string | First name entered by the user |
lastName | string | Last name entered by the user |
latitude | number | Latitude of the address |
longitude | number | Longitude of the address |
moduleCount | number | Number of solar panels displayed to the user on the solar model(1,2) |
monthlyOffset | number | monthlySavings divided by averageMonthlyBill as a percent(1,2) |
monthlySavings | number | Estimated monthly savings (cannot be larger than the averageMonthlyBill ) in dollars(1,2) |
orgId | string | Organization ID |
phone | string | Phone number entered by the user |
postalCode | string | Postal code of the address |
projectId | string | ID of the project |
referrerParams | object | See Passthrough Attributes for additional information |
state | string | State of the address |
street | string | Street of the address |
streetNumber | string | Street number of the address |
sunlightHours | number | Hours of usable sunlight as displayed to the user(1,2) |
systemSize | number | Total kW of the suggested design(1,2) |
2 Not present when contact information is submitted and the template is configured to have the lead contact form before the results.
results
Use this to get solar model information from Lead Capture AI. This event will be sent when:
- Results page is displayed
- Error page is displayed
const resultsCallback = (results) => {
console.log(results);
};
AuroraLeadCapture.addEventListener('results', resultsCallback);
The results
object will contain the following properties:
name | type | note |
---|---|---|
address | string | Full address, standardized according to google |
annualProduction | number | Total kWh produced in a year(1) |
averageMonthlyBill | number | What the user entered as their average monthly bill in dollars |
city | string | City of the address |
country | string | Country of the address |
error | boolean | true if Lead Capture fails to generate a solar model |
latitude | number | Latitude of the address |
longitude | number | Longitude of the address |
moduleCount | number | Number of solar panels displayed to the user on the solar model(1) |
monthlyOffset | number | monthlySavings divided by averageMonthlyBill as a percent(1) |
monthlySavings | number | Estimated monthly savings (cannot be larger than the averageMonthlyBill ) in dollars(1) |
orgId | string | Organization ID |
postalCode | string | Postal code of the address |
projectId | string | ID of the project |
referrerParams | object | See Passthrough Attributes for additional information |
state | string | State of the address |
street | string | Street of the address |
streetNumber | string | Street number of the address |
sunlightHours | number | Hours of usable sunlight as displayed to the user(1) |
systemSize | number | Total kW of the suggested design(1) |
open
Opens the Lead Capture Experience.
Usage
AuroraLeadCapture.open();
Returns
Void
setupCtas
Attaches a click event listener that will trigger AuroraLeadCapture.open()
to any DOM elements found matching the provided selector.
Usage
AuroraLeadCapture.setupCtas(selector);
Parameters
parameter | type | note |
---|---|---|
selector (required) | string | A selector to be used in querySelectorAll such as #selector or .selector |
Returns
Void