SOLVED

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

Go to solution
Frances_Wiseman
Level 2

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

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

Screen Shot 2020-02-19 at 9.54.27 AM.png

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

Screen Shot 2020-02-28 at 10.28.08 AM.png

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

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);
   }
})();

 

View solution in original post

4 REPLIES 4
Juliet_Crema
Level 2

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

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
Level 10 - Community Moderator

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

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.

 

SanfordWhiteman
Level 10 - Community Moderator

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

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);
   }
})();

 

SanfordWhiteman
Level 10 - Community Moderator

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

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