Pixel Tracking on a Marketo Form and not have a follow up URL. | Community
Skip to main content
Michael_Bollig
New Participant
October 16, 2020
Solved

Pixel Tracking on a Marketo Form and not have a follow up URL.

  • October 16, 2020
  • 1 reply
  • 3453 views

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! 🙂

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

Because you have a syntax error (you would see this in the browser console).  You also don't need the onload if you're not waiting for the pixel.

MktoForms2.whenReady(function (form) { var liPixelsrc="${pixelTracking}"; form.onSuccess(function (values, followUpUrl) { var liPixel = new Image(); liPixel.src=liPixelSrc; form.getFormElem().hide(); document.getElementById("confirmform").style.display = "block"; return false; }); });

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
October 16, 2020

Because you have a syntax error (you would see this in the browser console).  You also don't need the onload if you're not waiting for the pixel.

MktoForms2.whenReady(function (form) { var liPixelsrc="${pixelTracking}"; form.onSuccess(function (values, followUpUrl) { var liPixel = new Image(); liPixel.src=liPixelSrc; form.getFormElem().hide(); document.getElementById("confirmform").style.display = "block"; return false; }); });
Michael_Bollig
New Participant
October 16, 2020

@sanfordwhiteman Thank you for that catch!

 

I really need to brush up on my troubleshooting haha! 

 

When I click submit, It's now not processing the form...

Could this be because of the Marketo variable I'm using for the pixel tracking?

 

Edit: I'm currently embedding this into a landing page template. The problem I have with that is I use this landing page template for many of our webinars and they mostly don't use pixel tracking. Would this affect those pages? That's why I wanted to have the Marketo variable to change what the URL was inside the LP editor instead of making a new template just for one webinar

 

Also, My form is submitting on the backend. I'm receiving the confirmation email, but the page itself doesn't let me know that.

Michael_Bollig
New Participant
October 16, 2020

@sanfordwhiteman 

Sorry for all the replies. I think I found my issue. I had too many closing braces at the end. " }); "

 

I'm still curious if it's okay to have the ${pixeltracking} in JS. will that URL still pull in there?