Capture source, medium, and gclid in Pardot Form

gerard_reyes Posted by: Gerard Reyes Date Posted: September 24, 2024
Back to Case Studies

Issue

LMFX is tracking fine. But there are hidden fields in Pardot that are not being captured like source/medium/gclid which Nolan advised should be populating from custom JS automatically, but are not. Screenshot

Solution

I edited the Layout Template of the Form in Pardot to get the value from the UI and save it to the variable so it will be passed to LMFX for capturing.

mcfx(function(tracker) {
tracker.visitor.set(JSON.parse(event.data));
var input_utm_medium = document.getElementById('912231_20097pi_912231_20097');
if (input_utm_medium) {
input_utm_medium.value = tracker.visitor.get('m');
}
var input_utm_source = document.getElementById('912231_20099pi_912231_20099');
if (input_utm_source) {
input_utm_source.value = tracker.visitor.get('s');
}
var input_GCLID = document.getElementById('912231_20121pi_912231_20121');
if (input_GCLID) {
input_GCLID.value = tracker.visitor.get('gclid');
}
});

Achievement

Lead is captured with source, medium, and gclid.

Snippet/Screenshot/Link

Task: Link

Code: Screenshot