Direct JavaScript Installation
Install Leadbehavior on your website without Google Tag Manager. Use this method if you manage your scripts directly or use a tag management system other than GTM.
Note: This integration is currently available for Website leads only. Meta Business Leads and other lead types are processed automatically via webhook and don't require direct integration.
Prefer GTM?
If you use Google Tag Manager, the Community Template is the easiest way to install Leadbehavior.
Prerequisites
- A Leadbehavior account with an active subscription
- Your Account ID (found at app.leadbehavior.com/account)
- Your Lead ID (found at app.leadbehavior.com/leads)
The Bootstrap Script
The core Leadbehavior script sets up the window.leadbehavior object, loads the scoring library, and calls verify() with your lead configuration.
javascript
window.leadbehavior = window.leadbehavior || {
queue: [],
verify: function (options, callback) {
window.leadbehavior.queue.push([options, callback])
},
accountId: 'YOUR_ACCOUNT_ID',
}
if (!document.querySelector('[src*="static.leadbehavior.com/verify.js"]')) {
var s = document.createElement('script')
s.setAttribute('src', 'https://static.leadbehavior.com/verify.js')
s.setAttribute('crossorigin', true)
document.body.appendChild(s)
}
window.leadbehavior.verify(
{
'leadId': 'YOUR_LEAD_ID',
'orderId': 'YOUR_ORDER_ID', // A unique identifier for each conversion
},
function (score) {
console.log('leadbehavior score', score)
}
)Replace YOUR_ACCOUNT_ID, YOUR_LEAD_ID, and YOUR_ORDER_ID with your actual values.
Pre-filled Scripts
Each lead's detail page at app.leadbehavior.com/leads includes pre-filled script examples with your Account ID and Lead ID already populated. Click on a lead to view them.
How It Works
window.leadbehavior— Creates a global object with a queue pattern. Ifverify()is called before the script loads, calls are queued and replayed once the library is ready.verify.js— The Leadbehavior scoring library loaded fromstatic.leadbehavior.com. It collects a reCAPTCHA Enterprise token, browser fingerprint, click IDs (gclid, fbclid, dclid), and UTM parameters.verify(options, callback)— Sends the collected data to Leadbehavior for scoring. The callback receives the score result.
Installation Methods
Form Submission Listener
Trigger Leadbehavior when a specific form is submitted:
javascript
var leadForm = document.getElementById('lead-form') // Replace with your form's ID
leadForm.addEventListener('submit', function () {
// Paste the bootstrap script here
})Click Listener
Trigger Leadbehavior when a button is clicked:
javascript
var leadButton = document.getElementById('lead-button') // Replace with your button's ID
leadButton.addEventListener('click', function () {
// Paste the bootstrap script here
})GTM Custom HTML
If you use GTM but want more control than the template provides, paste the bootstrap script into a Custom HTML tag:
html
<script>
(function () {
// Paste the bootstrap script here
})()
</script>Set an appropriate trigger (form submission, custom event, etc.) in GTM.
The Order ID
The orderId parameter is a unique identifier for each conversion event.
- Google Ads requires an Order ID to match conversion adjustments to the original conversion
- Use a value that's unique per submission (e.g., a transaction ID, form submission ID, or generated UUID)
- Do not use GTM's Random Number variable — it generates a new value each time it's evaluated
Important
The Order ID you pass to Leadbehavior must match the Order ID sent to Google Ads for the same conversion. This is how Google Ads matches the adjustment to the original conversion event.
The Verify Callback
The verify() callback function receives the scoring result:
javascript
window.leadbehavior.verify(
{
'leadId': 'YOUR_LEAD_ID',
'orderId': 'YOUR_ORDER_ID',
},
function (score) {
// score contains the result from Leadbehavior
console.log('leadbehavior score', score)
}
)You can use the callback for custom logic — such as logging, analytics, or conditional behavior based on the score.
Troubleshooting
Script not loading
- Verify
https://static.leadbehavior.com/verify.jsis not blocked by ad blockers or Content Security Policy - Check the browser console for errors
- Ensure the script tag is being injected into the DOM
Score not returning in callback
- Verify your Account ID and Lead ID are correct
- Check that the lead exists and is not archived in your Leadbehavior account
- Review the browser console for error messages
Conversion adjustments not appearing in Google Ads
- Ensure the Order ID matches between your Google Ads conversion tag and the Leadbehavior tag
- Allow up to 24 hours — conversion adjustments are sent in a daily batch
Next Steps
- GTM Template Installation — if you decide to switch to the template approach
- Creating and Modifying Leads — configure conversion actions and adjustment values