Load pixel on Form Submit | Community
Skip to main content
Chirag_Agarwal1
New Participant
May 31, 2018
Solved

Load pixel on Form Submit

  • May 31, 2018
  • 1 reply
  • 7409 views

We're trying to integrate LinkedIn Ad conversion pixel with our Marketo form which links to a PDF file as Thank you URL.

The pixel tag is below:

<img src="dc.ads.linkedin.com/collect/?pid=xxxx&conversionId=xxxx&fmt=gif" height="1px">

Since LinkedIn tracks conversions based on number of times this pixel is loaded, is it possible to load this pixel only when the visitor hits Submit on the Marketo form?

Any thoughts/ideas or better ways to track conversions with LinkedIn Ads would be appreciated!

Best answer by SanfordWhiteman

Actually "when the visitor hits Submit" is not when you want to load a conversion pixel. I see people make this mistake all the time and it totally mangles their conversion numbers.

Hitting the Submit button doesn't mean the form was successfully submitted. Any validation error will reject the form, so you will get "conversion" after "conversion" and may not have a successful submission at all.

What you want to do is catch the Success event.

Like so:

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;

  });

});

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
May 31, 2018

Actually "when the visitor hits Submit" is not when you want to load a conversion pixel. I see people make this mistake all the time and it totally mangles their conversion numbers.

Hitting the Submit button doesn't mean the form was successfully submitted. Any validation error will reject the form, so you will get "conversion" after "conversion" and may not have a successful submission at all.

What you want to do is catch the Success event.

Like so:

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;

  });

});

Chirag_Agarwal1
New Participant
June 1, 2018

Definitely, the best way of doing this! Thank you Sanford