The LeadPulse JavaScript API provides methods for tracking events, identifying visitors, and managing consent programmatically.
Global Object
After the LeadPulse tracking code loads, a global window.LeadPulse object is available.
Core Methods
LeadPulse.track(eventName, properties)
Track a custom event with optional properties.
LeadPulse.track('button_click', {
button_name: 'Sign Up',
location: 'hero_section'
});
LeadPulse.track('product_viewed', {
product_id: 'prod_123',
category: 'electronics',
price: 50000
});LeadPulse.identify(traits)
Identify a known visitor with their traits.
LeadPulse.identify({
email: 'user@example.com',
name: 'John Doe',
company: 'Acme Inc',
plan: 'pro'
});LeadPulse.page(pageName, properties)
Track a page view (automatically called on page load).
LeadPulse.page('Product Page', {
category: 'Electronics',
product_id: 'prod_123'
});Consent Methods
LeadPulse.grantConsent()
Grant analytics consent and begin tracking.
if (window.LeadPulse) {
window.LeadPulse.grantConsent();
}LeadPulse.revokeConsent()
Revoke consent and stop tracking.
if (window.LeadPulse) {
window.LeadPulse.revokeConsent();
}LeadPulse.updateConsent(granted)
Update consent state based on boolean.
window.LeadPulse.updateConsent(true); // Grant
window.LeadPulse.updateConsent(false); // RevokeProperties
LeadPulse.consent.granted
Boolean indicating if consent has been granted.
if (window.LeadPulse.consent.granted) {
console.log('Tracking is active');
}LeadPulse.consent.analytics_storage
Google Consent Mode v2 compatible value.
console.log(window.LeadPulse.consent.analytics_storage);
// 'granted' or 'denied'Event Types
LeadPulse automatically tracks these events:
| Event | Description |
|---|---|
| page_view | Page load |
| click | Button/link clicks |
| scroll | Scroll depth milestones |
| form_submit | Form submissions |
| exit_intent | Mouse leaving viewport |
| session_start | New session begins |
| session_end | Session ends |