Pixel Tracking on a Marketo Form and not have a follow up URL.
Hello,
I saw the discussion about getting pixel tracking to work on the submit button correctly here. and down below:
MktoForms2.whenReady(function(form){
var liPixelsrc="https://dc.ads.linkedin.com/whatever/the/img/url/is";
form.onSuccess(function(vals,thankYouURL){
var liPixel = new Image();
liPixel.onload = function(e){
document.location.href = thankYouURL;
};
liPixel.src=liPixelSrc;
return false;
});
});
I've applied this the best way I could to my current landing page. The only difference is I added a Marketo variable to the tracking URL and I also don't want a follow up/thank you URL. I just want to hide the form and have some text come up.
This worked before I applied the tracking pixel method in there. I also moved a few things around. I have some basic knowledge of JS but am still not understanding what's going on wrong... Now when I fill out the form it seems that the page just refreshes instead of giving a thank you message on the current page. This is what I have now:
MktoForms2.whenReady(function (form){
//Add an onSuccess handler
var liPixelsrc="${pixelTracking}";
form.onSuccess(function(values, followUpUrl){
var liPixel = new Image();
liPixel.onload = function(e){
};
//get the form's jQuery element and hide it
liPixel.src=liPixelSrc;
form.getFormElem().hide();
document.getElementById('confirmform').style.display = 'block';
//return false to prevent the submission handler from taking the lead to the follow up url.
return false;
});
});
});
Thank you for the help ahead of time! 🙂