Overview
To unlock full-funnel tracking with LeadJourney, capturing the Click ID (lj_click_id
) on your lead forms is essential. This ID connects the original ad click with your CRM record and enables accurate offline conversion feedback to Meta, Google, and more.
In this guide, you'll learn how to:
✅ Retrieve the LeadJourney Click ID
✅ Automatically insert it into WPForms using JavaScript
✅ Ensure the ID persists and is submitted, even with dynamic form loads
Step 1: Add a Hidden Field to Your WPForm
In WordPress, go to WPForms → All Forms and edit your target form.
Add a Hidden Field to the form.
In the field settings:
Label: (optional, e.g. LeadJourney Click ID)
Field ID / Name:
lj_click_id
CSS Classes (under Advanced):
lj_click_id
Default Value:
{lj_click_id}
– this will be dynamically replaced.
Save the form when you're done.
Step 2: Add the Script to Populate the Click ID
Use the following JavaScript to fetch the LeadJourney Click ID and insert it into the hidden field automatically:
✅ Where to place this script:
Insert the script before </body>
using:
Elementor’s Custom Code (Header/Footer)
A plugin like Code Snippets
Your theme’s
footer.php
(advanced users only)
<script type="text/javascript">
async function getClickId(maxWait = 8000, poll = 250) {
const t0 = Date.now();
while (Date.now() - t0 < maxWait) {
if (window.lj?.getClickId && typeof window.lj.getClickId === 'function') {
try {
const id = await window.lj.getClickId();
if (id && typeof id === 'string') {
localStorage.setItem('clickid', id);
return id;
}
} catch {}
}
const ls = localStorage.getItem('clickid');
if (ls) return ls;
await new Promise(r => setTimeout(r, poll));
}
return null;
}
function fillClickFields(id) {
document.querySelectorAll('div.lj_click_id input[type="hidden"]').forEach(input => {
if (!input.value || input.value === '{clickid}') {
input.value = id;
}
});
}
async function ensureClickId() {
const id = await getClickId();
if (!id) return console.warn('No Click ID found.');
fillClickFields(id);
const tEnd = Date.now() + 5000;
const obs = new MutationObserver(() => {
fillClickFields(id);
if (Date.now() > tEnd) obs.disconnect();
});
obs.observe(document.body, { childList: true, subtree: true });
}
document.addEventListener('DOMContentLoaded', () => {
ensureClickId();
document.querySelectorAll('form.wpforms-form').forEach(form => {
form.addEventListener('submit', async e => {
const id = localStorage.getItem('clickid') || await getClickId();
if (!id) return;
form.querySelectorAll('div.lj_click_id input[type="hidden"]').forEach(i => {
i.value = id;
});
}, true);
});
});
window.addEventListener('load', ensureClickId);
</script>
Step 3: Test Your Setup
Open the page with your WPForm.
Open the browser console (F12 → “Console” tab).
Reload the page and look for logs such as:
"Click ID found:"
"Click ID successfully inserted:"
Submit the form and verify that
lj_click_id
was submitted with the data (check CRM or email).
Troubleshooting Tips
🚨 Click ID not being captured?
Ensure the field is named
lj_click_id
Confirm the div wrapping the field has the class
lj_click_id
Verify the script is loading (check console for errors)
Try a hard refresh or clear cache
🚨 Still seeing {
lj_click_id}
in the field?
This is expected—our script replaces it dynamically
Confirm that the form loads before the script runs (especially with AJAX-loaded forms)
🚨 Field not in submission?
Inspect the form HTML to confirm the input has the correct name and class
Ensure you're not using aggressive form validation plugins that remove unknown fields
Final Thoughts
With this integration, LeadJourney can now trace each submission back to its original click—unlocking powerful performance insights and enabling CRM-based conversion optimization.
✅ Works across dynamic forms and repeat visitors
✅ Requires no cookies or personal data
✅ Fully GDPR-compliant and performance-friendly
🚀 You’re now ready to track smarter with WPForms + LeadJourney!