Hyperlinked copy/CTA on Marketo Landing page counting as success/conversion | Community
Skip to main content
fwiseman
New Participant
February 28, 2020
Solved

Hyperlinked copy/CTA on Marketo Landing page counting as success/conversion

  • February 28, 2020
  • 3 replies
  • 3067 views

I have a B variant of this landing page with calls to action that are hyperlinked text:

How can clicks on these links as well as clicks from the buttons count as landing page conversions and be reported here:

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

First, you must tag the relevant <a> elements in a recognizable way, so the code knows which ones to link to hidden form conversions.

 

For example, a special class bind-form and an attribute data-form-id that indicates which Marketo form to post.

 

<a href="https://cloudagentsuite.com/fastrack/bundle/suite?mls_code=&amp;promo=fall2019tslb" class="bind-form" data-form-id="1234">Try it free until 2020.</a>

 

You'd create that form 1234 with no fields on the form in Form Editor, then add the form embed to the page, setting its <form> element to display:none;.

 

Then use some simple JS to bind the interesting links to the form, so a link click results in a form conversion before navigating to the new page:

 

(function(){ function bindLinks(){ var arrayify = getSelection.call.bind([].slice), formLinks = arrayify(document.querySelectorAll("a.bind-form")); formLinks.forEach(function(formLink){ formLink.addEventListener("click",function(e){ e.preventDefault(); var clickedLink = this, boundMktoForm; /* failsafe in case you forget to include Forms 2.0 lib and/or form embed */ try { boundMktoForm = MktoForms2.getForm(clickedLink.getAttribute("data-form-id")); } catch(e) { console.log("MktoForms2 library or related form not found, please fix."); } if (boundMktoForm) { boundMktoForm.onSuccess(resumeNavigation); boundMktoForm.submit(); } else { resumeNavigation(); } function resumeNavigation(){ document.location.href = clickedLink.href; return false; } }); }); } if (["complete","interactive"].indexOf(document.readyState) != -1) { bindLinks(); } else { document.addEventListener("DOMContentLoaded",bindLinks); } })();

 

3 replies

SanfordWhiteman
New Participant
March 3, 2020

@fwiseman please return to the thread and mark my answer as correct, thanks.

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
February 29, 2020

First, you must tag the relevant <a> elements in a recognizable way, so the code knows which ones to link to hidden form conversions.

 

For example, a special class bind-form and an attribute data-form-id that indicates which Marketo form to post.

 

<a href="https://cloudagentsuite.com/fastrack/bundle/suite?mls_code=&amp;promo=fall2019tslb" class="bind-form" data-form-id="1234">Try it free until 2020.</a>

 

You'd create that form 1234 with no fields on the form in Form Editor, then add the form embed to the page, setting its <form> element to display:none;.

 

Then use some simple JS to bind the interesting links to the form, so a link click results in a form conversion before navigating to the new page:

 

(function(){ function bindLinks(){ var arrayify = getSelection.call.bind([].slice), formLinks = arrayify(document.querySelectorAll("a.bind-form")); formLinks.forEach(function(formLink){ formLink.addEventListener("click",function(e){ e.preventDefault(); var clickedLink = this, boundMktoForm; /* failsafe in case you forget to include Forms 2.0 lib and/or form embed */ try { boundMktoForm = MktoForms2.getForm(clickedLink.getAttribute("data-form-id")); } catch(e) { console.log("MktoForms2 library or related form not found, please fix."); } if (boundMktoForm) { boundMktoForm.onSuccess(resumeNavigation); boundMktoForm.submit(); } else { resumeNavigation(); } function resumeNavigation(){ document.location.href = clickedLink.href; return false; } }); }); } if (["complete","interactive"].indexOf(document.readyState) != -1) { bindLinks(); } else { document.addEventListener("DOMContentLoaded",bindLinks); } })();

 

Juliet_Crema
New Participant
February 28, 2020

Do you have clicking those links as the success metric in the program or parent program that the LP is a part of? For example on my LP A/B test, the success metric of that campaign is them filling out a form and submitting it, so conversions are only tracked when that action is taken. 

SanfordWhiteman
New Participant
February 28, 2020

Knowing about this from Frances's other thread, the Idea is that a link click results also results in a hidden form post, so it appears in the same count (in the LP report).

 

I'll post the code for this later.

 

Definitely true, like you say, that using Program Status would allow the click to be a Success, but this is slightly outside that realm.